Zaheer Baloch
Zaheer Baloch

Reputation: 536

How to access request parameters in Struts2?

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.

Upvotes: 3

Views: 14660

Answers (2)

Brian Yarger
Brian Yarger

Reputation: 1975

Adding Zahieer's answer out of his comment so the question can be "answered":

<s:hidden name="myfield" value="%{#parameters['mparam']}"></s:hidden>

Upvotes: 6

andynu
andynu

Reputation: 722

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}" />

Upvotes: 2

Related Questions