- 浏览: 83980 次
- 性别:
- 来自: 广州
最新评论
-
nanjiwubing123:
头像是java之父。
AJAX中文乱码解决 -
nanjiwubing123:
不错 ,解决了问题。
AJAX中文乱码解决 -
nao000:
感谢您的帖子带给的帮助。
上传文件类型验证工具类 -
KevinGarnett:
这里为什么用\\: 而不是用\: 是因为:是非标准转义字符, ...
jQuery 特殊字符应该使用转义 -
gongmingwind:
写的非常好,多谢多谢
Struts1x项目开发中的统一异常处理
web.xml
applicationContext.xml
struts.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的配置的位置,可以定义多个配置文件,可以使用通配符。 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext*.xml</param-value> </context-param> <!--设置一起动当前的Web应用,就加载Spring,让Spring管理Bean--> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!--解决Hibernate延迟加载出现的问题,需要放到struts2过滤器之前--> <filter> <filter-name>lazyLoadingFilter</filter-name> <filter-class> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class> </filter> <!--Struts2的过滤器,使用Struts2,必须配置该项 --> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> </filter> <!--解决Hibernate延迟加载出现的问题,仍需要放到struts2过滤器mapping之前--> <filter-mapping> <filter-name>lazyLoadingFilter</filter-name> <url-pattern>*.action</url-pattern> </filter-mapping> <!--Struts2的过滤器,配套的filter-mapping --> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>
applicationContext.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/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" default-lazy-init="true"><!-- 延迟加载bean,加快应用服务器的启动速度 --> <!-- 定义数据源的Bean ,提供给Hibernate的sessionFactory--> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"> </property> <property name="url" value="jdbc:mysql://127.0.0.1:3306/test"> </property> <property name="username" value="root"></property> <property name="password" value="root"></property> </bean> <!-- 定义Hibernate的sessionFactory,通过该Bean,可以获得Hibernate的Session--> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.Oracle9Dialect </prop> <!--设置二级缓冲--> <prop key="hibernate.cache.provider_class"> org.hibernate.cache.EhCacheProvider </prop> <!--设置二级缓冲,打开查询缓冲--> <prop key="hibernate.cache.use_query_cache">true</prop> <!--设置显示Hibernate操作的SQL语句--> <prop key="hibernate.show_sql">true</prop> </props> </property> <property name="mappingResources"> <list> <value> cn/changtusoft/s2sh_compass/model/Product.hbm.xml </value> </list> </property> </bean> <!--======================== 事务配置 ========================--> <!-- 配置事务管理器 --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref local="sessionFactory"/> </property> </bean> <!-- 配置事务特性 ,配置add、delete和update开始的方法,事务传播特性为required--> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="insert*" propagation="REQUIRED"/> <tx:method name="delete*" propagation="REQUIRED"/> <tx:method name="update*" propagation="REQUIRED"/> <tx:method name="*" read-only="true"/> </tx:attributes> </tx:advice> <!-- 配置那些类的方法进行事务管理,当前cn.com.jobedu.oa.service包中的子包、类中所有方法需要,还需要参考tx:advice的设置 --> <aop:config> <aop:pointcut id="allManagerMethod" expression="execution (* cn.changtusoft.s2sh_compass.service.*.*(..))"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod"/> </aop:config> <!--======================== dao ========================--> <!-- 商品dao --> <bean id="productDao" class="cn.changtusoft.s2sh_compass.dao.hibernate.ProductDaoHibernate"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <!--======================== manager ========================--> <!-- 商品Manager --> <bean id="productManager" class="cn.changtusoft.s2sh_compass.service.impl.ProductManagerImpl"> <property name="productDao" ref="productDao"></property> <property name="compassTemplate" ref="compassTemplate"></property> </bean> <!--======================== action ========================--> <!-- 商品Action --> <bean id="productAction" class="cn.changtusoft.s2sh_compass.web.actions.ProductAction" scope="prototype"><!-- 多实例 --> <property name="productManager" ref="productManager"></property> </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="spring" /> <include file="struts-default.xml" /> <!-- 中文乱码解决 --> <constant name="struts.i18n.encoding" value="gbk"></constant> <package name="product" extends="struts-default" namespace="/product"> <action name="insert" class="productAction" method="insert"> <result>/product/product_insert_success.jsp</result> </action> <action name="search" class="productAction" method="search"> <result>/product/product_search_result.jsp</result> </action> </package> </struts>
发表评论
-
Java Thread Tech
2015-03-16 00:11 542user thread / daemon threadja ... -
Java Thread Tech
2015-03-16 00:10 0user thread / daemon threadjava ... -
移动支付-微信支付,中国银行支付交互图
2015-03-07 11:30 708以下是自己在做移动支付服务端时,画的支付交互时序图 ... -
OSCache页面缓存应用
2010-02-22 19:29 0OSCache页面缓存应用 -
上传文件类型验证工具类
2010-02-01 16:46 24431、定义合法文件类型的配置文件 allowuploadfil ... -
Tomcat访问地址映射配置
2010-01-08 09:42 4822实现的结果如: http://localhost: ... -
Compass对搜索关键字实现高亮显示
2010-01-07 08:49 1835例如搜"广东",实现后输出结果如 ... -
OSCache 缓存框架使用,方便应用到java开发的网站中
2010-01-05 08:51 2368OSCache标记库由OpenSymphony设计,它是 ... -
assert 是什么?
2010-01-04 00:04 1522assertion(断言)在软件开发中是一种常用的 ... -
struts2+spring+hibernate+compass 实现全文检索
2009-12-31 09:12 4149Compass是一流的开放源码JAVA搜索引擎框架,对 ... -
java序列化是什么,如何实现java序列化?
2009-12-30 08:50 1236序列化就是一种用来处理对象流的机制,所谓对象流也就 ... -
J2EE中一些常用的名词
2009-12-29 08:58 861web容器:给处于其中的应用程序组件(JSP,SERVLET) ... -
数据连接池的工作机制
2009-12-28 10:01 1288J2EE服务器启动时会建立一定数量的池连接,并一直 ... -
使用jspSmartUpload轻松实现上传和下载
2009-11-05 09:06 1137jspSmartUpload是由www.jspsm ... -
Struts2与Struts1的对比(推荐)
2009-11-03 22:24 7411、Action 类: Struts1要 ... -
定好项目规范的重要性
2009-11-02 23:28 1070近几个月都在忙于一个项目,由于需求的不明确,开始做的时 ... -
优秀java开源论坛 JForum,轻松搭建自己的论坛
2009-09-30 11:49 1481JForum 是一个功能强大 ,易于管理的论坛。它的 ... -
FreeMarker中文学习笔记
2009-09-24 17:09 718FreeMarker中文学习笔记。 -
多条件搜索的抽象实现
2009-09-24 17:02 0ColumnFields ColumnField -
Hibernate OneToOne双向关联为什么没有外键的一方不能Lazy加载?
2009-08-25 21:08 1669关联关系映射通常情况是比较难配置正确的。我觉得真正要掌握 ...
相关推荐
整合使用最新版本的三大框架(即Struts2、Spring4和Hibernate4),搭建项目架构原型。 项目架构原型:Struts2.3.16 + Spring4.1.1 + Hibernate4.3.6。 此外,还有:log4j、slf4j、junit4、ehcache等知识点。 项目...
轻量级Java EE企业应用实战(第4版) Struts 2+Spring 4+Hibernate整合开发 光盘 源码 2014 李刚
《轻量级Java EE企业应用实战:Struts2+Spring4+Hibernate整合开发(第4版)》是《轻量级Java EE企业应用实战》的第4版,第4版保持了前几版内容全面、深入的特点,主要完成全部知识的升级。 《轻量级Java EE企业...
struts2+spring2.5+hibernate3.2整合完整项目,带数据库脚本 ,mysql,tomcat,myeclipse完整工程
轻量级JavaEE企业应用实战_Struts2+Spring3+Hibernate整合开发_第3版.part2
轻量级JavaEE企业应用实战_Struts2+Spring3+Hibernate整合开发_第3版.part1
希望此套框架整合对深入了解和学校Struts2+Spring4+Hibernate4三大框架整合技术有帮助
轻量级JavaEE企业应用实战_Struts2+Spring3+Hibernate整合开发_第3版.part4
《轻量级java ee企业应用实战 第3版 struts 2+spring 3+hibernate整合开发》
Struts2+Spring4+Hibernate5整合
共分四个压缩包,JavaEE企业应用实战-Struts2+Spring3+Hibernate整合开发(第3版).part3
Struts1+Spring2+Hibernate2整合详细例子
Struts 2+Spring 3+Hibernate框架技术精讲与整合案例Struts 2+Spring 3+Hibernate框架技术精讲与整合案例Struts 2+Spring 3+Hibernate框架技术精讲与整合案例Struts 2+Spring 3+Hibernate框架技术精讲与整合案例...
Struts 2+Spring 3+Hibernate框架技术精讲与整合案例3Struts 2+Spring 3+Hibernate框架技术精讲与整合案例3Struts 2+Spring 3+Hibernate框架技术精讲与整合案例3
这是一个struts 1.2 + spring 2.5 + hibernate 3.2框架demo, 运行环境为eclipse 3.2 + tomcat 5.5 + oracle 11g
struts2 + spring 3 + hibernate3.3整合实现图书馆管理系统登陆和注册,以及一个对书籍表的增删改查,分页显示。
轻量级JavaEE企业应用实战_Struts2+Spring3+Hibernate整合开发_第3版.part5
必备软件 学习struts2项目struts2+spring4+hibernate 必备
struts2+spring+hibernate 配置文件struts2+spring+hibernate 配置文件
Struts2+Spring2+hibernate整合开发所需要的基本JAR包