Akshobhya
Akshobhya

Reputation: 139

How to send value using the achor tag in Struts 2?

How to send a value using <s:a> (the anchor tag) in Struts2? Please, give me an example, and I know we can achieve this using <s:url> tag, but I want it using the anchor tag.

Upvotes: -1

Views: 4419

Answers (2)

Roman C
Roman C

Reputation: 1

The anchor <s:a> tag in Struts2 as well as the other tags could be parametrized with the <s:param> tag. Just place param tag in the body of the anchor tag. For example

<s:a action="myaction"><s:param name="myparam" value="%{property}"/></s:a> 

Upvotes: 1

Dave Newton
Dave Newton

Reputation: 160321

Create it like any other parameterized link.

Personally, I prefer to use JSP EL:

<a href="displayMails?foo=${someActionProperty}">${subject}</a>

But if you insist on tags:

<a href="displayMails?foo=<s:property value='%{someActionProperty}'/>">
  <s:property value="%{subject}"/>
</a>

... To use the S2 action name in the HREF.

<a href="<s:url action='displayMails'/>?foo=${someActionProperty}">${subject}</a>

At this point we're back to having no idea why the S2 tag isn't what you actually want.

Upvotes: 1

Related Questions