Struts2配置

来源:互联网 发布:chalea高清网络电视 编辑:程序博客网 时间:2024/06/05 09:49

Struts2 配置

引包  (若缺少,则报错)



web配置 执行 struts.xml

 <filter><filter-name>struts2</filter-name><filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class></filter><filter-mapping><filter-name>struts2</filter-name><url-pattern>/*</url-pattern></filter-mapping>



struts.xml配置:


<package name="default" namespace="/" extends="struts-default"><action name="login" class="com.hst.struts2.LoginConter"><result>/login.jsp</result></action></package><package name="user" namespace="/user" extends="struts-default"><global-allowed-methods>regex:.*</global-allowed-methods><action name="user_*" class="com.hst.struts2.UserAction" method="{1}"><result name="add">/useradd.jsp</result><result name="dele">/userdele.jsp</result><result name="update">/userupdate.jsp</result><result name="sele">/usersele.jsp</result></action></package> 

Action 继承 ActionSupport 接口:
public class LoginConter extends ActionSupport{public String add(){return "add";}}