Struts2同时处理.do/.action后缀的请求
2015-01-08 16:58
302 查看
首先在 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>
这样struts就可以支持.do/.action后缀的请求。
转自:http://chy2z.blog.163.com/blog/static/316688462013721111929150/
配置如下:
<?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>
这样struts就可以支持.do/.action后缀的请求。
转自:http://chy2z.blog.163.com/blog/static/316688462013721111929150/
相关文章推荐
- struts处理.do后缀请求报Struts2中关于"There is no Action mapped for namespace / and action name"的总结
- struts2处理.do后缀的请求
- struts2处理.do后缀的请求
- [转]struts2处理.do后缀的请求
- 默认情况下,struts2是无法处理以.do为后缀的请求url的
- struts2处理.do后缀的请求
- struts2处理.do后缀的请求
- struts2默认无法处理以.do后缀的请求
- struts2处理.do后缀的请求
- struts2处理.do后缀的请求
- struts2处理.do后缀的请求
- struts2动态方法配置 Action,使一个Action可处理多请求
- Struts2 无后缀action请求
- struts2中Action处理多个请求(五)
- java发送url请求进行文件的提交以及后台struts2的action接收处理
- Struts2一个Action内包含多个请求处理方法的处理,method的使用方法,struts2中的路径问题,通配符映射
- 【Struts2学习笔记(4)】指定需要Struts 2处理的请求后缀和细说常量定义
- Struts2一个Action内包含多个请求处理方法的处理,method的使用方法,struts2中的路径问题,通配符映射 (
- 指定需要struts2处理的请求后缀
- 复习struts2之指定处理的请求后缀