Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>
</s:url>
<sj:div href="%{loadReportsForAPageInitial}">
</sj:div>

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?

UPDATE

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";
    options_div_1179027906.id = "div_1179027906";
    options_div_1179027906.href = "/FAP/loadReportsForAPage.action";
    options_div_1179027906.hrefparameter = "reportsCount_hidden=3&amp;pageNumber_hidden=1";
    jQuery.struts2_jquery.bind(jQuery('#div_1179027906'),options_div_1179027906);

});  
like image 332
SJ.Jafari Avatar asked Jan 29 '12 16:01

SJ.Jafari


People also ask

Which tag is used to create parameterized hyperlink in struts2?

You can use the <param> tag inside the body to provide additional request parameters.


1 Answers

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"
       value="/loadReportsForAPage.action" 
       escapeAmp="false">
like image 54
Sriharan Avatar answered Sep 24 '22 00:09

Sriharan