1.需要用到的jar包:由于很多的jar包不好下载,我直接上传到百度网盘:
很多,而且不好下载,我已经整理好好了:
关于SSM框架:以前的博客有介绍过
第一步:创建Dynamic Web Project
首先是整合之后的目录结构:
需要我们关注的只是我红线画出的:
先把所有的jar包复制入lib文件夹:不同于传统java项目,这里会自动build path,总之复制进去就完事了
关于mybatis和spring的配置文件,分别在两个文件夹中:
首先来配置mybatis:SqlMapConfig.xml:
/p>
"http://mybatis.org/dtd/mybatis-3-config.dtd">
配置Spring:
Dao层:applicationContext-dao.xml
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd">
Service层:applicationContext-service.xml:
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd">
配置SpringMVC:springmvc.xml
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
接下来就算最关键的一步:web.xml配置
SSM
index.html
index.htm
index.jsp
default.html
default.htm
default.jsp
contextConfigLocation
classpath:spring/applicationContext-*.xml
org.springframework.web.context.ContextLoaderListener
encoding
org.springframework.web.filter.CharacterEncodingFilter
encoding
UTF-8
encoding
/*
ssm
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:spring/springmvc.xml
1
ssm
/
其余的杂项配置:
1.数据库配置:用户名,数据库名,连接配置等等
jdbc.properties:
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/ssm?characterEncoding=utf-8
jdbc.username=root
jdbc.password=root
2.日志文件配置:
log4j.properties:
# Global logging configuration
log4j.rootLogger=DEBUG, stdout
# Console output...
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n
3.至于resource.properties是后边项目需要的,和SSM框架无关
最后:Get方式乱码修改方式:
打开Tomcat的配置文件修改一个URIEncoding属性