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