SJ.Jafari SJ.Jafari - 3 years ago 272
Ajax Question

Passing multiple parameters via a <s:url/> Struts2 tag

This code should send two parameters to the struts action:

<s:url id="loadReportsForAPageInitial" value="/loadReportsForAPage.action" >
<s:param name="reportsCount_hidden" value="3"></s:param>
<s:param name="pageNumber_hidden" value="1"></s:param>
<sj:div href="%{loadReportsForAPageInitial}">

the problem is only the first parameter's value is sent to the struts action and the second one is null! I changed the place of two parameters and again only the first one was fine.

Is it possible to pass more than one parameter via a s:url tag?


this is how the url tag is rendered:

<script type='text/javascript'>
jQuery(document).ready(function () {
var options_div_1179027906 = {};
options_div_1179027906.jqueryaction = "container"; = "div_1179027906";
options_div_1179027906.href = "/FAP/loadReportsForAPage.action";
options_div_1179027906.hrefparameter = "reportsCount_hidden=3&amp;pageNumber_hidden=1";


Answer Source

You may disable the URL escape behavior using escapeAmp="false" attribute. By default, this is enabled, so URL parameter & will render &amp;. This will cause a problem on reading the parameter value with parameter name.

  1. You may need to read the parameter, request.getParameter("amp;pageNumber_hidden")
  2. You have stop escaping the entities by adding attribute escapeAmp and set the value false as part of the <s:url> tag (Recommended)

<s:url id="loadReportsForAPageInitial"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download