struts2 spring hibernate3 的最精细的整合
来源:互联网 发布:windows rt8.1 编辑:程序博客网 时间:2024/05/16 15:30
整合struts2 spring Hibernate 的整合 最简单精细的整合
一: 新建web工程
二: 拷贝必要的包
http://hi.csdn.net/space-2177796-do-album-picid-489456.html
三:struts 配置(文件模板)
<?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>
<constant name="struts.objectFactory" value="spring"></constant>
<!—对于struts2.1.8来说上面的配置可有可无-->
<package name="default" namespace="/" extends="struts-default">
<action name="test" class="test" method="exec">
<result name="success">/success.jsp</result>
</action>
<action name="reg" class="reg" method="reg">
<result name="success">/reg-success.jsp</result>
</action>
</package>
</struts>
四:spring 配置文件:(模板文件,如何像下面那样,Hibernate的配置文件就不要了)
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Middle tier application context definition for the image database.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
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/context http://www.springframework.org/schema/context/spring-context-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"
destroy-method="close">
<property name="driverClassName"
value="com.mysql.jdbc.Driver">
</property>
<property name="url"
value="jdbc:mysql://localhost:3306/itcast">
</property>
<property name="username" value="root"></property>
<property name="password" value="root"></property>
<property name="maxActive" value="100"></property>
<property name="maxIdle" value="30"></property>
<property name="maxWait" value="500"></property>
<property name="defaultAutoCommit" value="true"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/test/bean/User.hbm.xml</value>
</list>
</property>
</bean>
<bean id="userDao" class="com.test.dao.UserDaoImpl">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="reg" class="com.test.action.RegAction">
<property name="userDao">
<ref bean="userDao" />
</property>
</bean>
</beans>
五:web.xml 的配置
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Struts Blank</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
六:测试吧 :我做的一个简单的工程,下面是缩略图:
没有什么验证功能,可以自己加上去。
http://hi.csdn.net/space-2177796-do-album-picid-489458.html
- struts2 spring hibernate3 的最精细的整合
- 最简单的 Struts2 Spring2 Hibernate3 整合 实例
- “Struts2+Hibernate3+Spring”整合项目基础JAR包的选择
- struts2+spring2+hibernate3 Annotation的整合
- struts2-spring2-hibernate3整合的一个问题
- spring3.0 + hibernate3.5 + struts2的整合
- Struts2+Hibernate3.2+Spring的整合配置(包的配置)
- 【Spring】Spring+Struts2+Hibernate3整合(十七)
- Hibernate3与spring的整合应用
- Hibernate3与spring的整合应用
- Struts2+Hibernate3.2+Spring 2.0整合应用
- spring+hibernate3+struts2整合完整配置
- spring+hibernate3+struts2整合完整配置
- eclipse整合Struts2+Spring 2.5+Hibernate3.2
- struts2+spring+hibernate3入门整合Demo
- (心得)Struts2+Spring2+Hibernate3.1的整合_Myeclipse6.0
- Struts2+Spring3+Hibernate3整合时遇到的包冲突问题
- struts2.1.8 + spring2.5.6 + hibernate3.3.2的整合
- 传智播客-多线程(1)-java里的进程和线程
- GUI编辑器
- 取坐标及变换
- 通过连接实现层级函数(4)
- C++面试题(有我做的答案,参考)
- struts2 spring hibernate3 的最精细的整合
- 疯狂java讲义----java顺序循环与java数组
- Symbian S60平台中状态面板的几种常用样式
- wampserver下配置虚拟主机 实现多站点支持
- Android activity类 【转】
- Applicaton of Digital Watermarking
- 网络游戏公司招聘C++程序员的笔试题(有我的答案)
- 我的第一个javaGUI程序
- C++引用类型