[Spring] SpringMVC jumps 404 error troubleshooting when using IDEA

1. Error

This kind of hateful mistake, I believe you must have seen many projects writing projects! ! ! I want to test the function I just wrote, and this 404 is really annoying

2. Eliminate errors

1. web.xml file

template

    <servlet>
        <servlet-name>springmvc</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:springmvc-servlet.xml</param-value>
        </init-param>

        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>springmvc</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

2. View section

       1. Whether the name of the view to jump to is the same as the configuration file, and the annotation method is also the same

       2. The configuration of the view resolver is also, the place of the / cannot be forgotten

3. No dependencies are imported when packaging

        When publishing to the Tomcat server, the corresponding dependency packages should be included. We have a deep understanding of this using eclipse. You can take a closer look at where your lib directory is placed when using eclipse.

Open ProjectStructrue via Ctrl+Alt+Shift+s shortcut

         Then import all

Guess you like

Origin blog.csdn.net/m0_56233309/article/details/124160105