function redirect(id){
alert(id);
document.forms[\"AddToCart\"].submit();
}
This is my javascript. How can i pass the value of \'id\' into AddToCa
We have to do two things to send a value to action class in struts2
create variable with the same name mentioned in jsp & create setter,getter methods for that variable.
in action class
public class AddToCart{
private String itemId;
public String getItemId(){
return itemId;
}
public void setItemId(String id){
this.itemId=id;
}
}
this will work.