SSH整合
来源:互联网 发布:甬温动车事故 知乎 编辑:程序博客网 时间:2024/06/02 10:43
struts-2.2.3.1 spring-framework-3.1.2 hibernate- 3.6.7整合。
可以看看Spring 连接池的配置 有JDBC、C3P0、BoneCP、Proxool。 http://blog.csdn.net/allen_gang/article/details/9067889
web.xml
<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <welcome-file-list> <welcome-file> index.jsp</welcome-file> </welcome-file-list> <!-- 加载spring配置文件applicationContext.xml --> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <!-- 指明spring配置文件在何处 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:beans.xml</param-value> </context-param> <!-- struts2用到的核心过滤器配置 --> <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> </web-app>
bean.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-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"> <!-- 用注解方式注入bean --><!--<context:annotation-config /><context:component-scan base-package="com.peacemap" />--><!-- 配置PropertyPlaceholderConfigurer方式的数据源 --><bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><property name="locations"><value>classpath:jdbc.properties</value></property></bean><bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="${jdbc.driverClassName}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> </bean> <!--定义一个hibernate的SessionFactory--><bean id="sessionFactory"class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"><property name="dataSource" ref="dataSource" /><property name="annotatedClasses"><list><value>com.tech.allen.model.User</value> </list></property><property name="hibernateProperties"><props><prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop><prop key="hibernate.show_sql">true</prop></props></property></bean><!-- 注入HibernateTemplate --><bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"><property name="sessionFactory" ref="sessionFactory"></property></bean><!--<bean id="txManager"class="org.springframework.orm.hibernate3.HibernateTransactionManager"><property name="sessionFactory" ref="sessionFactory" /></bean>--><!-- 业务逻辑组件 --> <!-- 用户管理 --><bean name="UserDao" class="com.tech.allen.dao.impl.UserDaoImpl"><property name="hibernateTemplate" ref="hibernateTemplate"></property></bean><bean name="UserService" class="com.tech.allen.service.impl.UserServiceImpl"><property name="UserDao" ref="UserDao"/> </bean><bean name="UserAction" class="com.tech.allen.action.UserAction"><property name="UserService" ref="UserService"/> </bean> </beans>
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><constant name="struts.objectFactory"value="org.apache.struts2.spring.StrutsSpringObjectFactory" /><!--<constant name="struts.objectFactory.spring.autoWire" value="type"/><constant name="struts.objectFactory" value="spring"/> <constant name="struts.devMode" value="false" /> --> <package name="json" extends="struts-default"> <!-- UserAction --> <!-- 用户 --> <action name="getUserList" class="UserAction" method="getUserList"> <result name="success" >success.jsp</result> </action> </package> </struts>
所需要jar文件 http://download.csdn.net/detail/allen_gang/5560593
- SSH 整合
- SSH整合
- ssh整合
- SSH整合
- SSH 整合
- SSH整合
- ssh整合
- SSH整合
- ssh整合
- SSH整合
- SSH整合
- SSH整合
- ssh整合
- SSH整合
- Ssh整合
- ssh 整合
- SSH整合
- SSH整合
- 只有神知道的世界
- wxPython构建一个简单的文本编辑器
- Ubuntu 网易更新源地址
- 水果忍者(二)
- 关键词加密
- SSH整合
- wxPython事件处理
- jsp中EL表达式的用法
- wxPython添加菜单
- NASM笔记
- Eclipse复制粘贴卡机的问题解决方法
- 他们可以偷走你的创意,但他们偷走不了你。他们偷走不了你的风格,你的创造力,以及你成功的动力——这才是使你的事业与众不同的地方
- Date类和Calendar类的使用
- 解决eclipse中overlaps the location of another project: 'xxxx'