项目结束,马上就要出去找工作了,这段时间也不用写项目,就整理了一些以后可能会用的到的配置,还有一个原因就是我不想去记忆。。。。。。。。。
SSH下application.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:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd "> <!-- 事务 --> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <!-- 链接点 --> <tx:advice id="txAvice" transaction-manager="txManager"> <tx:attributes> <tx:method name="find*" propagation="NOT_SUPPORTED" read-only="false" /> <tx:method name="query*" propagation="NOT_SUPPORTED" read-only="false" /> <tx:method name="save*" propagation="REQUIRED" /> <tx:method name="add*" propagation="REQUIRED" /> <tx:method name="delete*" propagation="REQUIRED" /> <tx:method name="update*" propagation="REQUIRED" /> <tx:method name="remove*" propagation="REQUIRED" /> <tx:method name="keep*" propagation="REQUIRED" /> </tx:attributes> </tx:advice> <!-- AOP切面 --> <aop:config> <aop:pointcut expression="execution(* com.hpsvse.xyz.qqzone.dao.impl.*.*(..))" id="myPoint" /> <aop:advisor advice-ref="txAvice" pointcut-ref="myPoint" /> </aop:config> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"> </property> <property name="url" value="jdbc:oracle:thin:@localhost:1521:orcl"> </property> <property name="username" value="QQZone"></property> <property name="password" value="qqzone"></property> </bean> <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> </props> </property> <property name="mappingResources"> <list> <!-- xml映射实体 --> <value> com/hpsvse/xyz/qqzone/entity/Friendmsg.hbm.xml </value> <value> com/hpsvse/xyz/qqzone/entity/Logact.hbm.xml </value> <value> com/hpsvse/xyz/qqzone/entity/Users.hbm.xml </value> <value> com/hpsvse/xyz/qqzone/entity/Message.hbm.xml </value> <value> com/hpsvse/xyz/qqzone/entity/Marks.hbm.xml </value> <value> com/hpsvse/xyz/qqzone/entity/Activitys.hbm.xml </value> <value>com/hpsvse/xyz/qqzone/entity/Dic.hbm.xml</value> <value>com/hpsvse/xyz/qqzone/entity/Say.hbm.xml</value> <value> com/hpsvse/xyz/qqzone/entity/Fridends.hbm.xml </value> <value> com/hpsvse/xyz/qqzone/entity/Album.hbm.xml </value> <value> com/hpsvse/xyz/qqzone/entity/Photo.hbm.xml </value> <value> com/hpsvse/xyz/qqzone/entity/Comments.hbm.xml </value> <value> com/hpsvse/xyz/qqzone/entity/Pwdprotect.hbm.xml </value> </list> </property> </bean> <!-- 开启注解 --> <context:annotation-config></context:annotation-config> <context:component-scan base-package="com.hpsvse.xyz.qqzone.*"></context:component-scan> </beans>
SSH下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"> <welcome-file-list> <welcome-file>login.jsp</welcome-file> </welcome-file-list> <!-- opensessionview --> <servlet> <servlet-name>ImageAction</servlet-name> <servlet-class>com.hpsvse.xyz.qqzone.web.action.ImageAction</servlet-class> </servlet> <servlet-mapping> <servlet-name>ImageAction</servlet-name> <url-pattern>/ImageAction</url-pattern> </servlet-mapping> <filter> <filter-name>opensessionview</filter-name> <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class> </filter> <filter-mapping> <filter-name>opensessionview</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- struts过滤器 --> <filter> <filter-name>strutsFilter</filter-name> <filter-class> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter </filter-class> </filter> <filter-mapping> <filter-name>strutsFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- 加载applicationContext.xml --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext*.xml</param-value> </context-param> <!-- 加载监听 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> </web-app>
本文出自 “IdLong” 博客,请务必保留此出处http://idlong.blog.51cto.com/10631184/1687652
原文地址:http://idlong.blog.51cto.com/10631184/1687652