I am having many problems while running some very common tasks in a struts2
web application. I just to create an anchor tag which will call some action.
I also want to pass some parameters. Below is what i am trying to do.
My action class name is MyAction. I define two string variables varA and
varB and added its setter and getters. I added MyAction in struts.xml.
1. I am creating the anchor tag as below:
<s:url id="myUrl" action="MyAction">
<s:param name="varA">6</s:param>
<s:param name="varB" value="%{myList[#myStat.index].myId}"></s:param>
</s:url>
<s:a href="%{myUrl}">delete</s:a>
This is producing the url like
http://localhost:8080/MyWebApp/web/MyAction.action?varA=6&varB=12
I am getting NumberFormatException at &varB. I tried to read this
parameter in many ways but it always returned null. varB is not found
anywhere.
2. Truly speaking i am facing so many problems with these s:url and s:a
tags. If i try to use html anchor <a tag, than i am unable to construct href
value, because i am in <s:iterator, and <a href="" is not identifying that.
3. One action is overriding another action. For example, i click a link with
paramter action=2, a jsp is displayed, than all the anchor tags in that jsp
page are showing action=2. Though i added a logic unique to each record.
I just dont know whats happening. If reading a simple querystring and
creating a hyperlink is so much difficult in this struts2 than i dont think
it will go very long. I am stuck in these basic things. Please help me.
--
Best Regards,
Faraz Ali