Home >Java >javaTutorial >JavaWeb project SSM configuration key points and solutions to possible problems

JavaWeb project SSM configuration key points and solutions to possible problems

黄舟
黄舟Original
2017-10-20 10:00:071903browse

The following editor will bring you an article based on the SSM configuration points of the javaWeb project, as well as possible problems and solutions. The editor thinks it is quite good, so I will share it with you now and give it as a reference for everyone. Let’s follow the editor and take a look.

I found that many important points were not mentioned when explaining the configuration of SSM (Spring, SpringMVC, Mybatis) for javaweb projects on the Internet. I will post some important configurations and possible problems. The problem is suitable for beginners to learn from

1. When creating a new javaweb project, you can select the relevant dependent libraries when creating a new one, or you can use maven to import them.

2. When importing dependent libraries from the outside, remember to also import them in the war, otherwise the relevant dependent libraries will not be found on the server and packaging will fail.

3. Configure


 <!--1、启动Spring的容器 -->
  <!-- needed for ContextLoaderListener -->
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext.xml</param-value>
  </context-param>

  <!-- springMVC核心配置 -->
  <!-- Bootstraps the root web application context before servlet initialization -->
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>

  <servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>

in web.xml. 4. After scanning the controller in the applicationContext, you can simply access the interface in the Controller

I will continue to follow up with myBatis on the relevant configuration of the database

The above is the detailed content of JavaWeb project SSM configuration key points and solutions to possible problems. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn