前端控制器DispatcherServlet的url-pattern中“/”和“/*”的深入分析

前端控制器DispatcherServlet的中/和/*的深入分析

博客的内容概述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
问题2:
在这里插入图片描述
但是到底是为什么呢?

在这里插入图片描述

The /* on a servlet overrides all other servlets, including all
servlets provided by the servletcontainer such as the default servlet
and the JSP servlet. Whatever request you fire, it will end up in that
servlet. This is thus a bad URL pattern for servlets. Usually, you’d
like to use /* on a Filter only. It is able to let the request
continue to any of the servlets listening on a more specific URL
pattern by calling FilterChain#doFilter().

在这里插入图片描述
在这里插入图片描述

he / doesn’t override any other servlet. It only replaces the
servletcontainer’s builtin default servlet for all requests which
doesn’t match any other registered servlet. This is normally only
invoked on static resources (CSS/JS/image/etc) and directory listings.
The servletcontainer’s builtin default servlet is also capable of
dealing with HTTP cache requests, media (audio/video) streaming and
file download resumes. Usually, you don’t want to override the default
servlet as you would otherwise have to take care of all its tasks,
which is not exactly trivial (JSF utility library OmniFaces has an
open source example). This is thus also a bad URL pattern for
servlets. As to why JSP pages doesn’t hit this servlet, it’s because
the servletcontainer’s builtin JSP servlet will be invoked, which is
already by default mapped on the more specific URL pattern *.jsp.

在这里插入图片描述
希望能帮到你!!!

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值