首先加入Struts2.14的JAR包,
再是HibernateJAR包
然后再是SpringJAR包
,由于是用idea开发,有些其他要用的的包没有自动增加,所也也要加进来,具体是
commons-dbcp.jar
commons-pool.jar
servlet-api.jar
ojdbc14.jar
包就这么多了。现在是配置文件:
web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/application*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!--这个openSessionInViewFitler要配在struts的Filter前面,否则会报,no session错 -->
<filter>
<filter-name>openSessionInViewFitler</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>openSessionInViewFitler</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
再是struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<!-- 与SPRING集成,类由SPRING生成 -->
<constant name="struts.objectFactory" value="spring" />
<!-- 开发模式,这样可以打印出更详细的错误信息 -->
<constant name="struts.devMode" value="true" />
<!-- 设置浏览器是否缓存静态内容,默认值为true(生产环境下使用),开发阶段最好关闭 -->
<constant name="struts.serve.static.browserCache" value="false" />
<!-- 当struts的配置文件修改后,系统是否自动重新加载该文件,默认值为false(生产环境下使用),开发阶段最好打开 -->
<constant name="struts.configuration.xml.reload" value="true" />
<!-- 编码格式-->
<constant name="struts.custom.i18n.resources" value="utf-8" />
<package name="ssh2" extends="struts-default" namespace="/">
<action name="login" class="loginAction">
<result name="success">/jsp/welcome.jsp</result>
<result name="error">/jsp/error.jsp</result>
</action>
<!--这里的class是spring中的bean id -->
<action name="myAction" class="myAction">
<result name="success">/jsp/listAction.jsp</result>
<result name="error">/jsp/error.jsp</result>
</action>
</package>
</struts>
application.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="url" value="jdbc:oracle:thin:test/123456@10.10.10.44:1521:testdb"></property>
<property name="username" value="test"></property>
<property name="password" value="123456"></property>
<property name="driverClassName" value="oracle.jdbc.OracleDriver"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
destroy-method="destroy">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.OracleDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/ssh/bean/User.hbm.xml</value>
<value>com/ssh/bean/Action.hbm.xml</value>
</list>
</property>
</bean>
<!--<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> -->
<!--hibernate 注解类
<property name="configurationClass">
<value>org.hibernate.cfg.AnnotationConfiguration</value>
</property> -->
<!--hibernate 配置文件
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>
-->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<tx:advice id="smAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="del*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="login*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="smMethod" expression="execution(* com.ssh.service.impl.*.*(..))" />
<aop:advisor advice-ref="smAdvice" pointcut-ref="smMethod"/>
</aop:config>
<bean id="loginAction" class="com.ssh.action.LoginAction" scope="prototype">
<property name="userService" ref="UserService"/>
</bean>
<bean id="myAction" class="com.ssh.action.MyAction">
<property name="actionService" ref="ActionService"/>
</bean>
</beans>
这样子应该就可以运行起来了
- 大小: 13.1 KB
- 大小: 2 KB
- 大小: 24 KB
分享到:
相关推荐
Myeclipse10下搭建S2SH框架(图解)Struts2.1+Spring3.0+Hibernate3.3.docx
Struts2.3 + Spring3.2 + Hibernate4.1 + HTML5 + CSS3开发示例代码。 其中包括如下文件: 介绍文档 Struts2.3 + Spring3.2 + Hibernate4.1 + HTML5 + CSS3开发示例.docx Eclipse工程文件 SSH2.zip Zip包是Eclipse...
此文档简单而明了的介绍了SSH环境搭建的每一个过程和细节以及各个配置文件的作用,搭建环境的每一步都进行测试过,都没有出现问题,直到最后项目的测试成功!
完善的S2SH整合程序,结合简单的注册程序
2.本程序为闲暇之余改写,暂时定为(1),在原来struts1+jpa+spring的基础上转为struts2+hibernate+spring版本; 3.因为是抽时间写的,所以不完善,问题是肯定存在的,望大家见谅; 4.目前只写了一个后台的产品管理...
适合初学者学习配置文件的配置,有助于养成分层的观念!
s2sh整合快速入门(strutc2.1+spring3.0+hibernate3.3)
s2sh代码-maven+spring4+hibernate4+struts2-登录注册的小demo(只是给讲了下如何使用该框架),参考博客:http://blog.csdn.net/lxfHaHaHa/article/details/79366330
自己研究了一个多星期了,咨询了好多高手,也看了好几个视频,终于做成了S2SH的整合。我的平台是:MyEclipse6.0、Sql Server 2000、...给一些还像我一样处在学习struts2+spring+hibernate整合阶段的朋友做下参考。
struts2+spring2.0+hibernate3.2+Security2.0的demo程序 里面带有 mysql的 DBdump, 可以直接导入DB S2SH的整合使用注解的方式 里面包括全部的jar包
S2SH(struts2+spring+hibernate)三大框架整合
Struts2.3.28+spring4.1.6+hibernate4.3.8整合总结(注解),测试环境使用myeclipse2014,jdk1.6
整合S2SH+Freemarker+oscache,后台用Spring管理各个bean,Hibernate做数据库持久化,viewer用Freemarker。整合中对Struts2,Hibernate,Spring都采用Annotation进行注解类。
struts2+spring4+hibernate4工程搭建源码 找对包最重要
s2sh整合总结(struts2.1.8-spring2.5-hibernate3.2) 三大框架
Struts2.1、Spring3.0、Hibernate3.3框架整合 Struts2.1、Spring3.0、Hibernate3.3框架整合 Struts2.1、Spring3.0、Hibernate3.3框架整合
整合S2SH+Freemarker,后台用Spring管理各个bean,Hibernate做数据库持久化,viewer用Freemarker。整合中对Struts2,Hibernate,Spring都采用Annotation进行注解类。
从网上找了好久都没有看到配置好的S2SH_DEMO,无奈自己写了一个,分享给大家使用
struts2.1 + hibernate3.2+spring2.5整合 给大家散发个S2SH整合视频,希望对大家有所帮助
Struts2.1、Spring3.0、Hibernate3.3整合与S2SH的XML文件拆分 很不错的整合实例 包括了s2sh框架的xml拆分