Various problems encountered when integrating SSM

book management project


Overall file structure:


The first small ssm project, the overall structure is not difficult to understand, and the code does not have any complicated logic, but there are many pitfalls! !


The build order of the projects

The java part of the three-tier architecture:

pojo->dao->service->controller

Integrate xml configuration:

mybatis-config >> spring-dao >> spring-service >> spring-mvc >> applicationContext.xml


  • The import of various jar packages and the filtering of Maven static resources should be solved in the early stage of project establishment, otherwise it is easy to delay the effect if it is reconfigured later
  • The project packaging method is a war package. You need to manually add the lib directory to the project structure and import various libraries, otherwise there will be a 500 server exception

  •  Regarding the inaccessibility of the mapping path in the controller layer under the control of Springmvc

    In the middle, the web project failed. It turns out that the special resource of web can be added, that is, there must be a small blue dot on the web folder, and it can be set in the project structure.

    • Check whether the Bean injection at each level is correct
    • Check that pathnames are consistent
    • Recreate the lib directory of the project structure
    • Check that the module path in the project structure is correct
    • Clear the cache of idea and restart
    • If it doesn’t work, create a new project and build it from scratch
  •  There have been various 500, 404, you should read the error message carefully, consult the information, and find the root cause of the problem.


    The jump relationship between the front-end pages must be clarified. The pages at the next level of the web cannot directly access the WEB-INF page. They must jump to the controller layer and access it through java code.


  • Various configurations, such as things, Aop, listeners, filters, view parsers, bean injection methods, interceptors, the use of json and ajax, etc., require more in-depth study, as well as the learning and use of front-end frameworks and js .


  • This is a small case of integrating the ssm framework, which must be written proficiently! !


  • Stubborn 404 problem solved:

  • Change the URL for registering the SpringMVC framework in web.xml from / to *.do as follows:

  • <url-pattern>/</url-pattern> 改为<url-pattern>*.do</url-pattern>

    <!--注册SpringMVC框架-->
        <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:applicationContext.xml</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>springmvc</servlet-name>
            <url-pattern>*.do</url-pattern>    
        </servlet-mapping>

    However, when implementing the subsequent control layer, you must pay attention to the request in .do format!

  • Github repository:

https://github.com/konan1024/ssmbuildicon-default.png?t=M276https://github.com/konan1024/ssmbuild

Guess you like

Origin blog.csdn.net/m0_57538148/article/details/123885954