日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

JSP教程之整合hibernate持久層1(2)_JSP教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:Spring學習基礎---與Struts整合
《Spring開發(fā)指南》只寫了一種與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

共2頁上一頁12下一頁
來源:模板無憂//所屬分類:JSP教程/更新時間:2010-03-04
相關JSP教程