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.

  • 相关阅读:
    jsp数据交互二
    jsp数据交互(一)
    JQuery操作DOM
    事件和动画
    Jquery选择器
    Optional容器(jdk1.8)
    java常见集合笔记
    字符串内存占用图解
    单例设计模式
    代码块
  • 原文地址:https://www.cnblogs.com/greatdreams/p/3501336.html
Copyright © 2011-2022 走看看