pass parameter from jsp to struts 2 action
Posted
by
andrey_groza
on Stack Overflow
See other posts from Stack Overflow
or by andrey_groza
Published on 2012-01-07T11:08:23Z
Indexed on
2012/09/25
3:38 UTC
Read the original article
Hit count: 107
I have an e-store application and I want to pass item id to the action every time the button for that item is pressed.
my jsp :
<s:submit value="addToCart" action="addToCart" type="submit">
<s:param name="id" value="%{#cpu.id}" />
</s:submit>
action:
public class ProductsCPU extends BaseAction implements Preparable, SessionAware {
private static final long serialVersionUID = 2124421844550008773L;
private List colors = new ArrayList<>();
private List cpus;
private String id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
When I print id to console, it has the NULL value. What is the problem?
© Stack Overflow or respective owner