Tomcat、web.xml、排除路径
在我的应用程序中,我需要在单个 servlet 中处理来自用户的所有请求,但是,我碰巧有一个包含静态内容的文件夹,我也希望静态提供该文件夹。
在我的 web.xml 文件中,我有以下内容:
<servlet>
<servlet-name>all</servlet-name>
<servlet-class>a.b.c.WidgetlistXml</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>all</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
有没有办法可以排除所有 .zip 文件?
附言。我知道以前在 StackOverflow 上有人问过这个问题,但最新的帖子是 2006 年左右的,而且它们也涉及 Spring 或其他框架。我没有使用任何内容,而且自 2006 年以来,url 模式可能发生了一些变化。顺便说一句,在 web.xml 上查找文档也不是那么简单。
先感谢您。
In my application, i need to process all the requests from users in a single servlet, however, i happen to have a folder with static content, which i would like to also serve statically.
In my web.xml file, i have the following:
<servlet> <servlet-name>all</servlet-name> <servlet-class>a.b.c.WidgetlistXml</servlet-class> </servlet> <servlet-mapping> <servlet-name>all</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping>
Is there a way i can exclude, say, all .zip files from this?
PS. I know this has been asked on StackOverflow before, but the latest posts were from about 2006, and they also concerned Spring or other frameworks. I use none, and since 2006 something could have changed in url-patterns. By the way, finding the docs on web.xml is not that simple either.
Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为您的静态内容设置一个
DefaultServlet
。这是一个例子:http://tomcat.apache.org/tomcat-7.0-doc /default-servlet.html#where
Set a
DefaultServlet
for your static contents. Here is an example:http://tomcat.apache.org/tomcat-7.0-doc/default-servlet.html#where