title: SpringMVC - Error using mvcUrl - Missing WebApplicationContext
body: <p>I am new to Spring MVC. I have basic Rest Controller and JSP. I want to be able to access the URL in the request mapping annotations from the JSP. I noticed that mvcUrl in Spring MVC 4.1 allows you to do that. But I run into an error when I try this: </p>
  
  <p>When I open <code>localhost/test.jsp</code>. I see this in the browser:</p>
  
  <pre><code>org.apache.jasper.JasperException: javax.el.ELException: Problems calling function 's:mvcUrl'
      org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:556)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477)    
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)    
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
      .....
  
  java.lang.IllegalArgumentException: Cannot lookup handler method mappings without WebApplicationContext
      org.springframework.util.Assert.notNull(Assert.java:115)
      org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder.getRequestMappingInfoHandlerMapping(MvcUriComponentsBuilder.java:521)
      org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder.fromMappingName(MvcUriComponentsBuilder.java:330)
      org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder.fromMappingName(MvcUriComponentsBuilder.java:313)
      sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      ....
  </code></pre>
  
  <p>Here is some sample code that I used</p>
  
  <pre><code>@RestController
  @RequestMapping("/foo")
  public class FooRestController {
      @RequestMapping(value = "/hello", method = RequestMethod.GET)
      public String hello() {
             return "hello";
      }
  }
  </code></pre>
  
  <p>JSP File - test.jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%&gt;
  &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %&gt;
  &lt;%@ taglib uri="http://www.springframework.org/tags" prefix="s" %&gt;
  
  &lt;a href="${s:mvcUrl('FRC#hello').build()}"&gt;Link to Hello&lt;/a&gt;
  </code></pre>
  
  <p>What could be setup wrong? </p>
  
  <p>When I hit <code>localhost/foo/hello</code> I do get back a json string  <code>"hello"</code>. Doesn't that mean the dispatcher servlet is working fine and the <code>WebApplicationContext</code> is actually setup properly?</p>