zoukankan      html  css  js  c++  java
  • A small configuration trick of Spring MVC web.xml

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

    ALL requests being made to your web app will be directed to the DispatcherServlet. This includes requests like /tasklist/, /tasklist/some-thing.html, /tasklist/WEB-INF/views/index.jsp.

    Because of this, when your controller returns a view that points to a .jsp, instead of allowing your server container to service the request, the DispatcherServlet jumps in and starts looking for a controller that can service this request, it doesn't find any and hence the 404.

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

    Notice the missing *. This tells the container that any request that does not have a path info in it (urls without a .xxx at the end), should be sent to the DispatcherServlet. With this configuration, when a xxx.jsp request is received, the DispatcherServlet s not consulted, and your servlet container's default servlet will service the request and present the jsp as expected.

  • 相关阅读:
    好玩的spring boot banner 图
    数据结构和算法二(数组)
    数据结构与算法三(链表)
    数据结构和算法一(基础知识)
    jenkins 部署node应用
    Docker-compose 安装Jenkins
    Docker 网络模式
    exe4j 转jar
    c#索引器的简单用法
    Adapter模式
  • 原文地址:https://www.cnblogs.com/greatdreams/p/3501336.html
Copyright © 2011-2022 走看看