码迷,mamicode.com
首页 > 其他好文 > 详细

懒人专用SSH框架下的基本配置

时间:2015-08-25 12:29:27      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:找工作   开发   项目   

    项目结束,马上就要出去找工作了,这段时间也不用写项目,就整理了一些以后可能会用的到的配置,还有一个原因就是我不想去记忆。。。。。。。。。

    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

懒人专用SSH框架下的基本配置

标签:找工作   开发   项目   

原文地址:http://idlong.blog.51cto.com/10631184/1687652

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!