【问题标题】:Catch-all (wildcard) servlet url-pattern overrides file extension patterns包罗万象(通配符)servlet url-pattern 覆盖文件扩展名模式
【发布时间】:2012-11-21 11:28:10
【问题描述】:

我想实现以下目标:

/webapp-context/Page-1               -> Handled by my custom "ContentServlet"
/webapp-context/Another-Page         -> Handled by my custom "ContentServlet"
/webapp-context/Page-with-long-title -> Handled by my custom "ContentServlet"

/webapp-context/_cms/<something>.zul -> Handled by ZK framework

我最近的尝试是这样的(web.xml 提取):

  <servlet-mapping>
    <servlet-name>zkLoader</servlet-name>
    <url-pattern>*.zul</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>myContentServlet</servlet-name>
    <url-pattern>/*</url-pattern>
  </servlet-mapping>

不幸的是,现在我的内容 servlet 处理所有请求(我认为更具体的模式优先?)。

如果我将我的内容 servlet 映射到模式“/webapp-context/content/*”,则不存在冲突,但这不是我想要的。

感谢您的宝贵时间。

【问题讨论】:

    标签: servlets web.xml zk url-pattern


    【解决方案1】:

    我刚刚通过这个问题找到了解决方案:Difference between / and /* in servlet mapping url pattern

    使用 '/' 而不是 '/*' 对我有用。

    <servlet-mapping>
      <servlet-name>myContentServlet</servlet-name>
      <url-pattern>/</url-pattern>
    </servlet-mapping>
    

    【讨论】:

      猜你喜欢
      • 2012-03-16
      • 1970-01-01
      • 1970-01-01
      • 2014-12-01
      • 1970-01-01
      • 2014-01-16
      • 1970-01-01
      • 1970-01-01
      • 2018-10-01
      相关资源
      最近更新 更多