加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – Dispatcher servlet spring和url模式

发布时间:2020-12-15 00:02:08 所属栏目:Java 来源:网络整理
导读:我是 spring框架的新手今天我遇到了web.xml文件中的调度程序servlet配置,我想出了一个关于url模式的问题,比如这个语法/.那么,如果我在tomcat服务器中部署web应用程序,实际上“/”符号适用的是:host:port /或host:port / myWeb / 解决方法 模式/将使您的se
我是 spring框架的新手今天我遇到了web.xml文件中的调度程序servlet配置,我想出了一个关于url模式的问题,比如这个语法/.那么,如果我在tomcat服务器中部署web应用程序,实际上“/”符号适用的是:host:port /或host:port / myWeb /

解决方法

模式/将使您的servlet成为应用程序的默认servlet,这意味着它将获取没有其他完全匹配的每个模式.

URL模式映射:

  • A string beginning with a / character and ending with a /* suffix is used for path mapping.
  • A string beginning with a *. prefix is used as an extension mapping.
  • A string containing only the / character indicates the default servlet of the application. In this case the servlet path is the request URI minus the context path and the path info is null.
  • All other strings are used for exact matches only.

路径映射规则:

  1. The container will try to find an exact match of the path of the request to the path of the servlet. A successful match selects the servlet.
  2. The container will recursively try to match the longest path-prefix. This is done by stepping down the path tree a directory at a time,using the / character as a path separator. The longest match determines the servlet selected.
  3. If the last segment in the URL path contains an extension (e.g. .jsp),the servlet container will try to match a servlet that handles requests for the extension. An extension is defined as the part of the last segment after the last . character.
  4. If neither of the previous three rules result in a servlet match,the container will attempt to serve content appropriate for the resource requested. If a default servlet is defined for the application,it will be used.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读