我是 Struts 的新手。我遇到了一个问题。我正在尝试将 JSP 表单值填充到 Action 类中,但我没有得到 Action 类中的值。有人可以告诉我是什么问题吗?这是我的 JSP。
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>
我的动作类——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>