Filter mapping for everything to Struts2 besides one servlet?(除了一个 servlet 之外,过滤器映射到 Struts2 吗?)
问题描述
我有一个 Struts2 (2.1.8.1) Web 应用程序.我的 web.xml 看起来像,
I have a Struts2 (2.1.8.1) web application. My web.xml looks like,
<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>/*</url-pattern>
</filter-mapping>
这被配置为将所有请求映射到 struts 过滤器.我想在我的 Web 应用程序中添加一个 servlet.我想将具有特定 url 模式的所有请求发送到该 servlet.我希望其他所有内容都转到我的 struts servlet.
This is configured to map all requests to the struts filter. I want to add a servlet in my web application. I want to send all requests with a certain url pattern to that servlet. I want everything else to go to my struts servlet.
我知道我只能将*.action"映射到 struts servlet,但我讨厌 .action 在我所有 URL 的末尾.
I know I could only map "*.action" to the struts servlet, but I hate .action being on the end of all my URL's.
推荐答案
在你的struts.xml中添加:
In your struts.xml add:
<constant name="struts.action.excludePattern" value="/ServletToExcludeFromStruts*"/>
对于多个排除项,该值也以逗号分隔.请参阅 http://struts.apache.org/2.2.1/docs/webxml.html
The value be comma delimited as well for multiple exclusions. See http://struts.apache.org/2.2.1/docs/webxml.html
这篇关于除了一个 servlet 之外,过滤器映射到 Struts2 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:除了一个 servlet 之外,过滤器映射到 Struts2 吗?
基础教程推荐
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- Struts2 URL 无法访问 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
