V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
freezex
V2EX  ›  Java

请教 servlet-mapping 的问题

  •  
  •   freezex · 2015-07-21 20:09:36 +08:00 · 2597 次点击
    这是一个创建于 3442 天前的主题,其中的信息可能已经有所发展或是发生改变。

    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

    有人明白我在说什么吗

    3 条回复    2015-07-21 20:42:25 +08:00
    Septembers
        1
    Septembers  
       2015-07-21 20:17:42 +08:00 via Android
    <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
        2
    loveyu  
       2015-07-21 20:18:22 +08:00 via Android
    使用/*/*试试
    phx13ye
        3
    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
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5461 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 07:35 · PVG 15:35 · LAX 23:35 · JFK 02:35
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.