1、struts.xml
<struts> <constant name="struts.devMode" value="true"> <constant name="struts.enable.DynamicMethodInvocation" value="true"> <package name="user" extends="struts-default"> <action name="user" class="com.wxh.action.UserAction"> <result>/useraddsuccess.jsp</result> </action> </package> </constant></constant></struts>2、UserAction.java
package com.wxh.action; import com.opensymphony.xwork2.ActionSupport; public class UserAction extends ActionSupport { private static final long serialVersionUID = 1L; private String name; private int age; public String add(){ System.out.println("name="+name); System.out.println("age="+age); return SUCCESS; } public String getName(){ return name; } public void setName(String name){ this.name=name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } }3、index,jsp
添加用戶4 useraddsuccess.jsp
user add success