0
我是Struts的新手。我遇到了一個問題。我正在嘗試在Action類中填充JSP表單值,但我沒有獲取Action類中的值。有人能告訴我什麼是問題?這是我的JSP。未在Struts中填充JSP表單值Action類
addEmployee.jsp
<a:form action="addEmployee">
<a:textfield name="eId" size="20" label="EmployeeID"/>
<a:textfield name="eName" size="20" label="EmployeeName"/>
<a:textfield name="eCity" size="20" label="EmployeeCity"/>
<a:submit value="ADD EMPLOYEE" ></a:submit>
</a:form>
我的Action類 - AddEmployeeAction.java
package com.action;
import com.opensymphony.xwork2.ActionSupport;
public class AddEmployeeAction extends ActionSupport{
/**
*
*/
private static final long serialVersionUID = 1L;
int eId;
String eName;
String eCity;
public AddEmployeeAction(){
}
@Override
public String execute() throws Exception{
System.out.println("*******Execute*******"+eId+eName+eCity);
return "success";
}
public int geteId() {
return eId;
}
public void seteId(int eId) {
this.eId = eId;
}
public String geteName() {
return eName;
}
public void seteName(String eName) {
this.eName = eName;
}
public String geteCity() {
return eCity;
}
public void seteCity(String eCity) {
this.eCity = eCity;
}
}
我的配置文件 - 在struts.xml
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="true" />
<package name="default" extends="struts-default" namespace="/">
<action name="addEmployee" class="com.action.AddEmployeeAction">
<result name="success">/response.jsp</result>
<result name="input">/addEmployee.jsp</result>
</action>
</package>
</struts>
非常感謝Dave。它正在工作。我使用Eclipse,並自動生成getter和setter。我沒有注意到命名約定。謝謝... – user2378183 2013-05-13 17:39:18