请教 servlet-mapping 的问题

2015-07-21 20:09:36 +08:00
 freezex

tomcat跑的flex网站

原本是这样的
<servlet-mapping>
<servlet-name>SpringServlet</servlet-name>
<url-pattern>/spring/*</url-pattern>
</servlet-mapping>

但是index.swf里设置的路径是
xx.xx.xx.xx/TTT/spring/xxxx
而不是
xx.xx.xx.xx/spring/xxxx

所以我就加了一条
<url-pattern>/TTT/spring/*</url-pattern>

然而并没有什么卵用

比如我访问这个就有反应
xx.xx.xx.xx/spring/messagebroker/streamingamf
访问这个就404
xx.xx.xx.xx/TTT/spring/messagebroker/streamingamf

有人明白我在说什么吗

2597 次点击
所在节点    Java
3 条回复
Septembers
2015-07-21 20:17:42 +08:00
<servlet-mapping>
<servlet-name>SpringServlet</servlet-name>
<url-pattern>/spring/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>SpringServlet</servlet-name>
<url-pattern>/TTT/spring/*</url-pattern>
</servlet-mapping>
loveyu
2015-07-21 20:18:22 +08:00
使用/*/*试试
phx13ye
2015-07-21 20:42:25 +08:00
Key rules about servlet mappings
1) The Container looks for matches in the order shown on the opposite
page. In other words, it looks first for an exact match. If it can’t find an
exact
match, it looks for a directory match. If it can’t find a
directory
match,
it looks for an
extension
match.
2) If a request matches more than one directory <url-pattern>, the
Container chooses the longest mapping. In other words, a request for /foo/
bar/myStuff.do will map to the <url-pattern> /foo/bar/* even though it also
matches the <url-pattern> /foo/*. The most
specific
match always wins.

http://stackoverflow.com/questions/8995353/many-url-pattern-for-the-same-servlet

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/207330

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX