title: Spring 3.0.6 MVC @PathVariable and @RequestParam blank/empty in JSP view
body: <p>I have been trying to get an incredibly simple controller/view set up, and just can't make it work. In my <code>web.xml</code>, I've defined a <code>&lt;servlet&gt;</code> called <code>servlet-context.xml</code>, which is running ok. In <code>servlet-context.xml</code>, I've set:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:mvc="http://www.springframework.org/schema/mvc"
  
  &lt;...other stuff in here... /&gt;
  
  &lt;mvc:annotation-driven /&gt;
  </code></pre>
  
  <p>among other things. My understanding is this is all that's needed to use <code>@</code> annotations.</p>
  
  <p>In my controller, I have:</p>
  
  <pre><code>@RequestMapping(value="/student/{username}/", method=RequestMethod.GET)
  public String adminStudent(@PathVariable String username, @RequestParam String studentid) {
      return "student";
  }
  </code></pre>
  
  <p>And in my <code>student.jsp</code> view, I have:</p>
  
  <pre><code>&lt;p&gt;This is the page where you would edit the stuff for ${username}.&lt;/p&gt;
  &lt;p&gt;The URL parameter &lt;code&gt;studentid&lt;/code&gt; is set to ${studentid}.&lt;/p&gt;
  </code></pre>
  
  <p>When I make a request to <code>http://localhost:8080/application/student/xyz123/?studentid=456</code>, I get the view I expect, but all the variables are blank or null:</p>
  
  <pre><code>&lt;p&gt;This is the page where you would edit the stuff for .&lt;/p&gt;
  &lt;p&gt;The URL parameter &lt;code&gt;studentid&lt;/code&gt; is set to .&lt;/p&gt;
  </code></pre>
  
  <p>I suspect it's a problem with the way my <code>web.xml</code> or <code>servlet-context.xml</code> are set up, but I can't find the culprit anywhere. There's nothing showing up in any logs as far as I can see.</p>
  
  <hr>
  
  <p>Update: I was basing my code off this part of the <a href="https://github.com/SpringSource/spring-mvc-showcase/blob/master/src/main/java/org/springframework/samples/mvc/views/ViewsController.java" rel="noreferrer">spring-mvc-showcase</a>:</p>
  
  <pre><code>@RequestMapping(value="pathVariables/{foo}/{fruit}", method=RequestMethod.GET)
  public String pathVars(@PathVariable String foo, @PathVariable String fruit) {
      // No need to add @PathVariables "foo" and "fruit" to the model
      // They will be merged in the model before rendering
      return "views/html";
  }
  </code></pre>
  
  <p>...which works fine for me. I can't understand why this example works but mine doesn't. Is it because they're <a href="https://github.com/SpringSource/spring-mvc-showcase/blob/master/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml" rel="noreferrer">doing something different</a> with <code>servlet-context.xml</code>?</p>
  
  <pre><code>&lt;annotation-driven conversion-service="conversionService"&gt;
      &lt;argument-resolvers&gt;
          &lt;beans:bean class="org.springframework.samples.mvc.data.custom.CustomArgumentResolver"/&gt;
      &lt;/argument-resolvers&gt;
  &lt;/annotation-driven&gt;
  </code></pre>