title: Trying to use a @RequestParam field in Spring form
body: <p>If I have a Spring form as follows:</p>
  
  <pre><code>&lt;c:url value="/user/profile?id=${user.id}" var="profileURL" /&gt;  
      &lt;form:form action="${profileURL}" method = "get"&gt;                       
          &lt;input type="submit" value="My profile"&gt;                           
      &lt;/form:form&gt;   
  </code></pre>
  
  <p>Spring complains that:</p>
  
  <pre><code>Your page request has caused a MissingServletRequestParameterException: Required String parameter 'id' is not present error:
  </code></pre>
  
  <p>However, in the controller method, the parameter is present:</p>
  
  <pre><code>@RequestMapping(value = "/profile", method = RequestMethod.GET)
  public String getProfile(@RequestParam("id") String id, Model model) {    
  
      User user = userService.get(Integer.parseInt(id));         
      model.addAttribute("user", user);
      return "profile";
  }
  </code></pre>
  
  <p>Can anyone advise why this is?</p>
  
  <p>If I use a simple form field like: </p>
  
  <pre><code>&lt;input name="id" type="hidden" value="=${user.id}"&gt;  
  </code></pre>
  
  <p>Everything is good. But I prefer to use a Spring field, hidden of necessary.</p>
  
  <p>At run-time the form looks like this:</p>
  
  <pre><code>&lt;form id="command" action="/nameOfapplication/user/profile?id=3" method="get"&gt;                       
          &lt;input type="submit" value="My profile"&gt;                           
      &lt;/form&gt;   
  </code></pre>
  
  <p>This causes the following messages in the stacktrace:</p>
  
  <blockquote>
    <p>Your page request has caused a
    MissingServletRequestParameterException: Required String parameter
    'id' is not present error:</p>
    
    <p>org.springframework.web.method.annotation.RequestParamMethodArgumentResolver.handleMissingValue(RequestParamMethodArgumentResolver.java:255)</p>
  </blockquote>