V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
RoxyBrowser - 轻盈、安全的指纹浏览器
Roxy 凭借领先的指纹反追踪技术,助力隐私保护、跨境电商、数据采集等场景,为您的卓越事业保驾护航。
Promoted by RoxyBrowser
freezex
V2EX  ›  Java

请教 servlet-mapping 的问题

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

    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   ·   实用小工具   ·   1006 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 19:16 · PVG 03:16 · LAX 12:16 · JFK 15:16
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.