The 404 problem of the SSM framework

How to return the returned 404 original page to its own specific 404 page in the SSM framework after random input in the address bar

1. Add the following configuration in web.xml

  <!--配置错误的输入后返回的默认404界面-->
    <error-page>
        <error-code>404</error-code>
        <location>/WEB-INF/view/mainContextThirdPage.jsp</location>
    </error-page>

Note: The /WEB-INF/view/mainContextThirdPage.jsp configuration in /WEB-INF/view/mainContextThirdPage.jsp here is the relative path of the custom 404 interface you want to jump to
2. Add the following to the spring-mvc configuration file Configuration

<!--页面错误后返回指定页面404的配置-->
    <mvc:default-servlet-handler/>

Note: The configuration here will hand over the wrong 404 interface to the static resource processor
. 3. Try the effect

Published 19 original articles · praised 7 · visits 6636

Guess you like

Origin blog.csdn.net/William_TWG/article/details/84867214