关于SSH整合时要用的一些模板
来源:互联网 发布:noteledge mac 编辑:程序博客网 时间:2024/06/05 21:01
首先是beans.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:context="http://www.springframework.org/schema/context"
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/context
http://www.springframework.org/schema/context/spring-context-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">
<context:annotation-config/>
/*添加数据源*/
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
<property name="url" value="jdbc:mysql://localhost:3306/main?useUnicode=true&characterEncoding=gbk">
</property>
<property name="username" value="root"></property>
<property name="password" value=""></property>
<property name="initialSize" value="1"/>
<property name="maxActive" value="500"/>
<property name="maxIdle" value="2"/>
<property name="minIdle" value="1"/>
</bean>
/*添加sessionfactory*/
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="mappingResources">
<list>
<value></value>/*添加映射文件*/
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect /* 数据库语言*/
</prop>
</props>
</property>
</bean>
/*添加事务*/
<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/></bean>
/*添加事务注解*/
<tx:annotation-driven transaction-manager="txManager" proxy-target-class="true"/>
/*添加你需要配置的Bean*/
</beans>
Struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<constant name="struts.i18n.encoding" value="gbk"/>
<constant name="struts.action.extension" value="action"/>
<constant name="struts.serve.static.browserCache" value="false"/>
<constant name="struts.configuration.xml.reload" value="true"/>
<constant name="struts.devMode" value="false" />
<constant name="struts.objectFactory" value="spring" /> /*将struts交给spring管理*/
<package name="stu" namespace="/" extends="struts-default" >
<action></action> /*t添加action*/ 注意 :action中的class调用的是beans.xml的action的id; 不是包名加类名!
</package>
</struts>
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">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:beans.xml</param-value>
</context-param>
<!-- 对Spring容器进行实例化 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<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>
- 关于SSH整合时要用的一些模板
- 关于SSH框架的一些整合要点
- SSH整合-关于web.xml的一些配置
- 关于SSH整合时遇到的一些问题
- SSH整合的一些经验
- ssh整合的一些异常
- 关于SSH整合的问题
- SSH整合实用模板
- SSH整合开发的一些总结
- SSH整合遇到的一些问题
- SSH整合出现的一些问题
- SSH整合-关于Spring中applicationContext.xml文件对于事务的一些配置
- 关于SSH的一些总结
- struts2之整合sitemesh(关于过滤一些不使用模板文件的注意事项)
- 关于SSH整合的一点心得
- 关于SSH整合所遇到的坑
- 关于SSH整合的那些事
- 关于模板的一些知识
- 类微博@好友功能
- linux--- 配置ftp服务
- 利用Python获取天气信息
- 不错的代码
- 红白蓝三色小球排列成有序的红白蓝三色的同颜色在一起的小球组
- 关于SSH整合时要用的一些模板
- 在调用支持可变参数格式化的函数时的一个很掩蔽问题
- C++ 习题 输出日期时间--友元函数
- Light OJ 1047
- Spring BeanFactory实例化Bean的过程
- js获取url参数值
- (Java)冒泡排序
- AFNetwork 2.0在请求时报错code=-1016 和 3840
- 第一篇博文——测试一下