How to access request parameters in Struts2?
14,442
Solution 1
Adding Zahieer's answer out of his comment so the question can be "answered":
<s:hidden name="myfield" value="%{#parameters['mparam']}"></s:hidden>
Solution 2
If you add a String getMyParam(),setMyParam(String val) to the action rendering the form then you can use
<s:hidden name="myfield" value="${myParam}" />
Comments
-
Zaheer Baloch almost 2 years
I am trying to access request parameters on a web page and trying to set a hidden fields value to the passed parameter. How can I achieve this using struts2 tags?
Something like...
<s:hidden name="myfield" value="#parameters['myparam']"/>
I have tries using the parameters object but it does not work!
Thanks in advance.
-
Ammad over 7 yearsThanks, this is what i am looking.