Spring参考手册 mvc:default-servlet-handler

 

Spring参考手册 mvc:default-servlet-handler

This tag allows for mapping the DispatcherServlet to "/" (thus overriding the mapping of the container's default Servlet), while still allowing static resource requests to be handled by the container's default Servlet.
这个标签吧DispatcherServlet 映射到"/"(从而覆盖容器的默认servlet的映射),也允许容器默认的servlet处理静态资源的请求。
//我感觉这句的意思就是:DispatcherServlet把找不到的请求映射到默认的servlet,从而实现处理静态资源的请求。不知理解的对不对?

It configures a DefaultServletHttpRequestHandler with a URL mapping (given a lowest precedence order) of "/**".
This handler will forward all requests to the default Servlet.
配置了DefaultServletHttpRequestHandler最后来处理"/**"的请求。
这个处理器会把所有的请求跳转到容器默认servlet。

To enable this feature using the default setup, simply include the tag in the form:
标签的默认设置就可以实现这个功能:
<mvc:default-servlet-handler/>
The caveat to overriding the "/" Servlet mapping is that the RequestDispatcher for the default Servlet must be retrieved by name rather than by path.
覆盖"/"映射会导致默认servlet的RequestDispatcher必须用名字取回而不是路径。(不知道什么意思,是不是跟下一句有关联呐,使用名字找默认servlet)

The DefaultServletHttpRequestHandler will attempt to auto-detect the default Servlet for the container at startup time, using a list of known names for most of the major Servlet containers (including Tomcat, Jetty, Glassfish, JBoss, Resin, WebLogic, and WebSphere).
DefaultServletHttpRequestHandler在容器启动是会使用主流web容器默认servlet的名称列表自动查找容器的默认servlet,包括Tomcat, Jetty, Glassfish, JBoss, Resin, WebLogic, and WebSphere。

If the default Servlet has been custom configured with a different name, or if a different Servlet container is being used where the default Servlet name is unknown, then the default Servlet's name must be explicitly provided as in the following example:
如果为默认servlet配置了新的名称,或者这个容器servlet名字不在spring列表中是,必须显式配置默认servlet的名字,如下:
<mvc:default-servlet-handler default-servlet-name="myCustomDefaultServlet"/>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值