Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

passing parameter between pages in struts2 using hyperlink

 
sarin jacob
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<a href=edit.jsp?id="<%=UserID %>">edit</a>

This is thae code i want to convert to struts2 format.

I tried

<s:url id="editUrl" action="edituser2" >
<s:param name="id" value="%{UserID}" />
</s:url>
<s:a href="%{editUrl}">Edit</s:a>

and

<s:url id="editUrl" action="edituser2" >
<s:param name="id" value="%{UserID}" />
</s:url>
<s:a href="<%=UserID %>">Edit</s:a>
but still its not working... Any 1 could help me?

In struts.xml

<action name="edituser2" class="com.action.edituseraction">
<result name="useredit" type="tiles">edituser1</result>
</action>

and in action class

package com.action;
import java.util.ArrayList;
import com.opensymphony.xwork2.ActionSupport;
public class edituseraction extends ActionSupport{
private static final long serialVersionUID = -2613425890762568273L;


private String id;

public String execute() {
System.out.println(id);
return "useredit";

}
public String getid() {
System.out.println(id);
return id;
}
public void setid(String value) {
System.out.println(id);
this.id = value;
} }


This is what i tried
 
sarin jacob
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It worked

<a href=edituser2?&id="<%=UserID %>">edit</a>

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic