Struts + Spring + Hibernate to streamline the preparation of [file]

1.web.xml

<? Xml version = "1.0" encoding = "UTF-8"?>
<Web-app xmlns = "http://java.sun.com/xml/ns/j2ee"
xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" version = "2.4"
xsi: schemaLocation = "http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

<context-param>
<param-name> contextConfigLocation </ param-name>
<param-value> / WEB-INF/applicationContext *. 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>
<init-param>
<param-name> config </ param-name>
<param-value>
/ WEB-INF/struts-config.xml, / WEB-INF/struts-config-form.xml, / WEB-INF/struts-config-action.xml
</ Param-value>
</ Init-param>
<init-param>
<param-name> debug </ param-name>
<param-value> 3 </ param-value>
</ Init-param>
<init-param>
<param-name> detail </ param-name>
<param-value> 3 </ param-value>
</ Init-param>
<load-on-startup> 0 </ load-on-startup>
</ Servlet>
<servlet-mapping>
<servlet-name> action </ servlet-name>
<url-pattern> *. do </ url-pattern>
</ Servlet-mapping>
<session-config>
<session-timeout> 120 </ session-timeout>
</ Session-config>

<! - The Usual Welcome File List ->
<welcome-file-list>
<welcome-file> login.jsp </ welcome-file>
</ Welcome-file-list>

<! - Tag Library Descriptors ->
<jsp-config>
<taglib>
<taglib-uri> / WEB-INF/tld/struts-bean.tld </ taglib-uri>
<taglib-location>
/ WEB-INF/tld/struts-bean.tld
</ Taglib-location>
</ Taglib>
<taglib>
<taglib-uri> / WEB-INF/tld/struts-html.tld </ taglib-uri>
<taglib-location>
/ WEB-INF/tld/struts-html.tld
</ Taglib-location>
</ Taglib>
<taglib>
<taglib-uri> / WEB-INF/tld/struts-logic.tld </ taglib-uri>
<taglib-location>
/ WEB-INF/tld/struts-logic.tld
</ Taglib-location>
</ Taglib>
<taglib>
<taglib-uri> / WEB-INF/tld/struts-nested.tld </ taglib-uri>
<taglib-location>
/ WEB-INF/tld/struts-nested.tld
</ Taglib-location>
</ Taglib>
<taglib>
<taglib-uri> / WEB-INF/tld/struts-template.tld </ taglib-uri>
<taglib-location>
/ WEB-INF/tld/struts-template.tld
</ Taglib-location>
</ Taglib>
<taglib>
<taglib-uri> / WEB-INF/tld/struts-tiles.tld </ taglib-uri>
<taglib-location>
/ WEB-INF/tld/struts-tiles.tld
</ Taglib-location>
</ Taglib>
</ Jsp-config>
</ Web-app>

2.applicationContext-persistence.xml

<? Xml version = "1.0" encoding = "UTF-8"?>
<! DOCTYPE beans PUBLIC "- / / SPRING / / DTD BEAN / / EN"
"Http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>

<! - Configure Data Source ->
<Bean

destroy-method = "close">
<property name="driverClassName">
<value> oracle.jdbc.driver.OracleDriver </ value>
</ Property>
<property name="url">
<value> jdbc: oracle: thin: @ localhost: 1521: ora9i </ value>
</ Property>
<property name="username">
<value> tom </ value>
</ Property>
<property name="password">
<value> tom </ value>
</ Property>
</ Bean>

<! - Configure Hibernate ->
<Bean
>
<property name="dataSource">
<ref local="dataSource" />
</ Property>
<property name="mappingResources">
<list>
<value> com / example / entity / User.hbm.xml </ value>
</ List>
</ Property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</ Prop>
<prop key="hibernate.show_sql"> true </ prop>
</ Props>
</ Property>
</ Bean>

<! - Configure Services ->
<Bean
>
<property name="sessionFactory">
<ref local="sessionFactory" />
</ Property>
</ Bean>

<Bean
>
<property name="transactionManager" ref="transactionManager" />
<property name="transactionAttributes">
<props>
<prop key="find*"> PROPAGATION_REQUIRED, readOnly </ prop>
<prop key="save*"> PROPAGATION_REQUIRED </ prop>
<prop key="update*"> PROPAGATION_REQUIRED </ prop>
<prop key="delete*"> PROPAGATION_REQUIRED </ prop>
</ Props>
</ Property>
</ Bean>

<Bean
>
<property name="proxyTargetClass">
<value> true </ value>
</ Property>
<property name="beanNames">
<list>
<value> * Service </ value>
</ List>
</ Property>
<property name="interceptorNames">
<list>
<value> transactionInterceptor </ value>
</ List>
</ Property>
</ Bean>

</ Beans>

3.applicationContext-action.xml

<? Xml version = "1.0" encoding = "UTF-8"?>
<! DOCTYPE beans PUBLIC "- / / SPRING / / DTD BEAN 2.0 / / EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>

<! - Example ->
<bean name="/login">
<property name="userService">
<ref bean="userService" />
</ Property>
</ Bean>

</ Beans>

4.applicationContext-service.xml

<? Xml version = "1.0" encoding = "UTF-8"?>
<! DOCTYPE beans PUBLIC "- / / SPRING / / DTD BEAN 2.0 / / EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>

<! - Example ->
<Bean
>
<property name="userDAO">
<ref bean="userDAO" />
</ Property>
</ Bean>

</ Beans>

5.applicationContext-dao.xml

<? Xml version = "1.0" encoding = "UTF-8"?>
<! DOCTYPE beans PUBLIC "- / / SPRING / / DTD BEAN 2.0 / / EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>

<! - Example ->
<bean>
<property name="sessionFactory">
<ref bean="sessionFactory" />
</ Property>
</ Bean>

</ Beans>

6.struts-config.xml

&

struts2.0.14 + hibernate3.2 + spring2.5.6 + to ... | hibernate configuration file Xiangjie

  • 21:49
  • View (0)
  • Comments (0)
  • Category: Java
  • Related Recommendation
Comment
Comment
分类:Java 时间:2010-08-04 人气:158
分享到:
blog comments powered by Disqus

相关文章

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.302 (s). 12 q(s)