JSP教程之整合hibernate持久层1(2)_JSP教程
教程Tag:暂无Tag,欢迎添加,赚取U币!
推荐:Spring学习基础---与Struts整合《Spring开发指南》只写了一种与struts整合的方法,另一种到Spring2.0 Demo自带的Doc中查找到Action直接继承ActionSupport。详细信息: TointegrateyourStrutsapplicationwithSpring,youhavetwooptions: ConfigureSpringtomanageyourActionsasbeans,usingtheCo
原来包含很多复杂内容的applicationContext.xml也拷贝一份applicationContext2.xml,删除和JPetStore相关的内容,留下通用的部分:
<?xml version="1.0" encoding="UTF-8"?> <!-- - Application context definition for JPetStore’s business layer. - Contains bean references to the transaction manager and to the DAOs in - dataAccessContext-local/jta.xml (see web.xml’s "contextConfigLocation"). --> <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.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>WEB-INF/mail.properties</value> <value>WEB-INF/jdbc.properties</value> </list> </property> </bean> <aop:config> <aop:advisor pointcut="execution(* *..PetStoreImpl.*(..))" advice-ref="txAdvice"/> </aop:config> <!-- Transaction advice definition, based on method name patterns. Defaults to PROPAGATION_REQUIRED for all methods whose name starts with "insert" or "update", and to PROPAGATION_REQUIRED with read-only hint for all other methods. --> <tx:advice id="txAdvice"> <tx:attributes> <tx:method name="insert*"/> <tx:method name="update*"/> <tx:method name="*" read-only="true"/> </tx:attributes> </tx:advice> </beans> |
在Struts配置文件中增加自己的Action如下:
<action path="/showusers" type="srx.test.struts.action.UserAction"> <forward name="success" path="/WEB-INF/jsp/srx/test/hibernate/showusers.jsp"/> </action> |
web.xml中使用action作为*。do处理的servlet而不是默认的petstore。
并注释掉名字为petstore,remoting的servlet。如下:
<web-app 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" version="2.4"> <display-name>Spring JPetStore</display-name> <description>Spring JPetStore sample application</description> <context-param> <param-name>webAppRootKey</param-name> <param-value>petstore.root</param-value> </context-param> <context-param> <param-name>log4jConfigLocation</param-name> <param-value>/WEB-INF/log4j.properties</param-value> </context-param> <context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/dataAccessContext-hibernate.xml </param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <load-on-startup>3</load-on-startup> </servlet> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> ... </web-app> |
分享:解读Spring异常处理配置Spring异常处理之需要增加一个bean的配置: !--ExceptionResolver-- beanid=exceptionResolverclass=org.springframework.web.servlet.handler.SimpleMappingExceptionResolver propertyname=defaultErrorView value/exception/failure/value /prop
相关JSP教程:
- jsp response.sendRedirect不跳转的原因分析及解决
- JSP指令元素(page指令/include指令/taglib指令)复习整理
- JSP脚本元素和注释复习总结示例
- JSP FusionCharts Free显示图表 具体实现
- 网页模板:关于jsp页面使用jstl的异常分析
- JSP页面中文传递参数使用escape编码
- 基于jsp:included的使用与jsp:param乱码的解决方法
- Java Web项目中连接Access数据库的配置方法
- JDBC连接Access数据库的几种方式介绍
- 网站图片路径的问题:绝对路径/虚拟路径
- (jsp/html)网页上嵌入播放器(常用播放器代码整理)
- jsp下显示中文文件名及绝对路径下的图片解决方法
- 相关链接:
- 教程说明:
JSP教程-JSP教程之整合hibernate持久层1(2)。