Reputation: 61
I am trying to pass multiple parameters to my Struts action class using <html:link>
tag.
I am having a link, it should take two parameters from the JSP page to my action class.
How to achieve this?
Upvotes: 1
Views: 9858
Reputation: 1
In Struts 1.3 parameters could be set to the action
attribute like in this example
<html:link action="/path/to/action?param1=2¶m2=${param2Value}">Some text</html:link>
Upvotes: 3
Reputation: 9
why don't you go with ajax calling ? by using ajax you can pass many parameter to action class by set the method K
Upvotes: 0
Reputation: 692081
Quote from the documentation:
If you prefer to specify a java.util.Map that contains all of the request parameters to be added to the hyperlink, use one of the following techniques:
- Specify only the name attribute - The named JSP bean (optionally scoped by the value of the scope attribute) must identify a java.util.Map containing the parameters.
- Specify both name and property attributes - The specified property getter method will be called on the bean identified by the name (and optional scope) attributes, in order to return the java.util.Map containing the parameters.
As the Map is processed, the keys are assumed to be the names of query parameters to be appended to the hyperlink. The value associated with each key must be either a String or a String array representing the parameter value(s), or an object whose toString() method will be called. If a String array is specified, more than one value for the same query parameter name will be created.
Supplmenting these two methods, you can nest one or more tags to dynamically add parameters in a logic-friendly way (such as executing a for loop that assigns the name/value pairs at runtime). This method does not compete with the aforementioned; it will adds its parameters in addition to whatever parameters are already specified.
You can also use a regular HTML <a>
tag and create the URL using the standard <c:url>
tag from the JSTL.
Upvotes: 1