SSH整合,非常详细的SSH整合

这是一个eclipse基于maven整合的struts2-spring-hibernate的简单项目,

1,首先创建一个maven项目如下:名字可以自己命名

SSH整合,非常详细的SSH整合_第1张图片

创建好之后如下图:

SSH整合,非常详细的SSH整合_第2张图片会报错,为什么呢?因为这是一个不完整的maven项目,缺少web.xml。

右键点击项目,如下操作,会自动补全web.xml文件

补全的如下图所示:

SSH整合,非常详细的SSH整合_第3张图片,好了一个完整的maven骨架就好了。

 

2, 向 pom.xml 导入 ssh所需要的相关 jar包 和 tomcat 7 插件

 

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.struts2-spring-hibernate.zh
struts2-spring-hibernate.zh
0.0.1-SNAPSHOT
war
ssh
这是一个struts2-spring-hibernate的整合




3.2.12.RELEASE

3.6.10.Final

2.3.15.3

1.7.5

0.9.1.2

5.0.8

2.5

2.0

4.11




org.springframework
spring-context
${spring.version}


org.springframework
spring-aspects
${spring.version}


org.springframework
spring-orm
${spring.version}


org.springframework
spring-web
${spring.version}


org.springframework
spring-test
${spring.version}




org.hibernate
hibernate-core
${hibernate.version}



org.slf4j
slf4j-log4j12
${slf4j.version}



c3p0
c3p0
${c3p0.version}



mysql
mysql-connector-java
${mysql.version}
runtime



org.apache.struts
struts2-core
${struts2.version}


org.apache.struts
struts2-spring-plugin
${struts2.version}


org.apache.struts
struts2-json-plugin
${struts2.version}



org.apache.struts
struts2-convention-plugin
${struts2.version}



javax.servlet
servlet-api
${servlet.version}
provided


javax.servlet
jsp-api
${jsp.version}
provided



junit
junit
${junit.version}
test






org.apache.tomcat.maven
tomcat7-maven-plugin
2.1

80
/




 

3,ssh 下的web.xml配置文件 


  struts2-spring-hibernate.zh



contextConfigLocation
classpath:applicationContext.xml



org.springframework.web.context.ContextLoaderListener





struts2
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter



struts2

/*


index.html
index.htm
index.jsp
default.html
default.htm
default.jsp

4,log4j日志的配置

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %5p (%c:%L) - %m%n

log4j.rootLogger=info, stdout

5,数据库连接信息配置

driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/demo?useUnicode=true&characterEncoding=utf-8
user=root

passwd=123456

6,配置applictionContext.xml如下


xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx 
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">




 
































 

7,配置struts.xml配置如下,自己根据需要的可以自己添加


"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">










 
 
 
 
 
 
 
   
 
 
 
 
    



 
























/index.jsp



 

注意说明:此项目还有待重新编写,有写错误,请暂时先参考其他的博客介绍,谢谢

 

  

 

 

 

 

你可能感兴趣的:(ssh整合)