修改struts2的action的后缀名

来源:互联网 发布:linux ip地址拒绝访问 编辑:程序博客网 时间:2024/05/16 00:33
首先在 web.xml  配置如下:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name></display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.do</url-pattern>
<url-pattern>*.action</url-pattern>

</filter-mapping></web-app>
 

其次在 struts.xml 配置如下

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<constant name="struts.action.extension" value="do,action"/>

<package name="login" extends="struts-default" namespace="/">
<action name="login*" class="code.common.action.LoginAction" method="login_{1}">
<result name="success">/page/default/login_success.jsp</result>
<result name="failure">/page/default/login_failure.jsp</result>
</action>
</package>
</struts>
0 0