JavaWeb项目SSM配置要点及可问题的解决方法

下面小编就为大家带来一篇基于javaWeb 项目SSM配置要点及可能遇到的问题和解决方法。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧

我发现网上许多讲解javaweb 项目 SSM(Spring,SpringMVC,Mybatis)配置的时候有些重点没有提到,一下我会贴上一些重要的配置和可能出现问题的地方,适合初学者借鉴

1. 新建javaweb项目是可以在新建的时候就选择相关依赖库,也可以用maven导入。

2.在从外部导入依赖库的时候记住要在war 中也导入,否则在服务器上就会找不到相关的依赖库,打包就会失败。

3. 在web.xml 中 配置

 <!--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>

4. 在applicationContext中扫描controller后 就可以简单的访问到Controller中的接口了

后面会继续跟进myBatis对数据库想相关配置

以上就是JavaWeb项目SSM配置要点及可问题的解决方法的详细内容,更多请关注其它相关文章!

每天告诉自己一次,『我真的很不错』

JavaWeb项目SSM配置要点及可问题的解决方法

相关文章:

你感兴趣的文章:

标签云: