Panadol Chong Panadol Chong - 1 year ago 69
Java Question

How to get data from JSP to Action class by id instead of property in Struts 2?

I am doing on Java Struts 2 framework.

Normally, I can get data from my JSP through the get set method in
(action class). Below is my example :


<html:text property="campaignName" size="50" maxlength="50" />

thus, I can get this text box name by get set method in the action class, the below is code from

private String campaignName = null;

public String getCampaignName() {
return campaignName;

public void setCampaignName(String campaignName) {
this.campaignName = campaignName;

However, because of I want to use jQuery to do something, I no longer use
as text box, but I use
<input type="text" id="datepicker" />

Because of without property attribute inside this text box, I cant get the value from this text box. I have tried to add
inside the text box also, but get set method in
is return

I would like to ask, how can I get the value by this text box?

Answer Source
<s:textfield name="campaignName" size="50" maxlength="50" />    


<input type="text" name="campaignName" size="50" maxlength="50" />

The name need to be matched with the field name

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download