title: Spring MVC - Set an actionURL parameter with Javascript
body: <p>Is it possible to dynamically set a Spring MVC portlet:actionURL portlet:param using javascript?  I have tried with the following code, but the id value always comes across as null to the controller. I have verified that setting the portlet:param manually passes the value correctly:</p>
  
  <pre><code>&lt;portlet:param name="id" value="2" /&gt;
  </code></pre>
  
  <p>I have also verified the value in the javascript is being set correctly and is not null.  </p>
  
  <p><strong>(Note: I've changed the variable names, etc. from the original code to simplify it and obfuscate it since it is my employer's code.)</strong></p>
  
  <p>JSP:</p>
  
  <pre><code>&lt;portlet:actionURL var="modifyURL"&gt;
      &lt;portlet:param name="do" value="modify" /&gt;
      &lt;portlet:param name="id" value="${model.id}" /&gt;
  &lt;/portlet:actionURL&gt;
  
  ...
  
  &lt;form:form action="${modifyURL}" id="modifyForm" modelAttribute="model"&gt;
      &lt;form:hidden path="id" id="id" /&gt;
  &lt;/form:form&gt;
  </code></pre>
  
  <p>Javascript called when the update URL is clicked:</p>
  
  <pre><code>function update() {
      document.forms[0]["id"].value = selectedId;
      document.forms[0].submit();
  }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>@RequestMapping(params = {"do=modify"})
  public void modify(@ModelAttribute("model") Model model, 
      @RequestParam(value = "id", required=true) Long id,
      ActionRequest request, ActionResponse response,
      SessionStatus sessionStatus, ModelMap modelMap)  {
  ....
  </code></pre>