81,091
社区成员
发帖
与我相关
我的任务
分享
spring-mvc.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:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
<!-- 开启注解 -->
<mvc:annotation-driven />
<!-- 静态资源(js/image)的访问 -->
<mvc:resources location="/static/" mapping="/static/**"/>
<mvc:interceptors>
<mvc:interceptor>
<!-- 设置拦截的路径 -->
<mvc:mapping path="/**" />
<mvc:exclude-mapping path="/static/**"/>
<mvc:exclude-mapping path="/page/index/login.jsp"/>
<bean class="com.rlst.pm.interceptor.SessionInterceptor">
<!-- openingTime 属性指定不被拦截的路径 -->
<property name="uri">
<value>/index/login</value>
</property>
</bean>
</mvc:interceptor>
</mvc:interceptors>
<!-- 定义视图解析器 -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
<!-- 注解扫描包 -->
<context:component-scan base-package="com.rlst.pm">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
</beans>
spring-commons.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:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
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/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<!-- 配置数据源 -->
<!-- <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" > -->
<!-- <property name="driverClassName" value="dm.jdbc.driver.DmDriver"></property> -->
<!-- <property name="url" value="jdbc:dm://192.168.1.100:12345/RLST"></property> -->
<!-- <property name="username" value="PM"></property> -->
<!-- <property name="password" value="123456"></property> -->
<!-- </bean> -->
<bean id="dataSource" class="com.rlst.pm.utils.db.DataSource" >
<property name="driverClassName" value="dm.jdbc.driver.DmDriver"></property>
<!-- <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"></property> -->
<property name="username" value="PM"></property>
<property name="password" value="123456"></property>
<property name="url" value="jdbc:dm://localhost:12345/RLST"></property>
<!-- <property name="url" value="jdbc:oracle:thin:@localhost:1521:orcl"></property> -->
<!-- 连接池启动时的初始值 -->
<property name="initialSize" value="10"/>
<property name="maxActive" value="100"/>
<property name="maxIdle" value="10"/>
<property name="minIdle" value="10"/>
</bean>
<!-- 配置SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Dm6Dialect</prop>
<prop key="hibernate.hbm2ddl.auto">none</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="current_session_context_class">thread</prop>
<prop key="hibernate.current_session_context_class">org.springframework.orm.hibernate4.SpringSessionContext</prop>
</props>
</property>
<property name="annotatedClasses">
<list>
<value>com.rlst.pm.entity.User</value>
<value>com.rlst.pm.entity.Role</value>
<value>com.rlst.pm.entity.Permission</value>
</list>
</property>
</bean>
<!-- 配置一个事务管理器 -->
<bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<tx:annotation-driven transaction-manager="txManager"/>
<context:component-scan base-package="com.rlst.pm" >
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
</beans>