classpath:springmvc.xml

<servlet>
	<servlet-name>dispatcherServlet</servlet-name>
	<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class
	<init-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:springmvc.xml</param-value>
	</init-param>
如果不用<init-param>指定的springmvc配置文件的路径,那么DispatcherServlet会自动到/WEB-INF下找指定名字的配置文件
默认配置文件名为<servlet-name>-servlet.xml
</servlet>
<servlet-mapping>
	<servlet-name>dispatcherServlet</servletname>
		匹配所有资源除了jsp
		/*匹配所有资源包括jsp
	<url-pattern>/</url-pattern>
<servlet-mapping>

默认去/WEB-INF/dispatcherServlet-servlet.xml找SpringMVC对应的配置

url-pattern   /   不匹配jsp    /*匹配所有包括jsp

  • 12
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
<?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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:oscache="http://www.springmodules.org/schema/oscache" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springmodules.org/schema/oscache http://www.springmodules.org/schema/cache/springmodules-oscache.xsd"> <context:annotation-config/> <!-- 扫描包 --> <context:component-scan base-package="com.org"/> <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> <!-- 匹配jsp文件下面的所有.jsp的页面 --> <property name="prefix" value="/jsp/" /> <property name="suffix" value=".jsp" /> </bean> <!-- <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/" p:suffix=".jsp" />--> <!-- 配置jdbc --> <bean class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer"> <property name="locations"> <value>classpath:jdbc.properties</value> </property> </bean> <!-- 配置數據源 --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${jdbc.driver}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <!-- 连接池启动时的初始值 --> <property name="initialSize" value="1"/> <property name="maxActive" value="500"/> <property name="maxIdle" value="2"/> <property name="minIdle" value="1"/> </bean> <!-- 定义Ibatis配置 org.springframework.orm.ibatis.SqlMapClientFactoryBean --> <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"> <property name="configLocation"> <value>classpath:ibatis-Base.xml</value> </property> <property name="dataSource"> <ref bean="dataSource"/> </property> </bean> <!-- 配置sqlMapClientTemplate模板 --> <bean id="sqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate"> <property name="sqlMapClient" ref="sqlMapClient"/> </bean> <!-- 配置 transactionManager事物管理--> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"/> </bean> <!-- Spring AOP config配置切点 --> <aop:config> <aop:pointcut expression="execution(* com.org.service.*.*(..))" id="bussinessService" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="bussinessService"/> </aop:config> <!-- 配置那个类那个方法用到事务处理 --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="get*" read-only="true"/> <tx:method name="add*" propagation="REQUIRED"/> <tx:method name="update*" propagation="REQUIRED"/> <tx:method name="delete*" propagation="REQUIRED"/> <tx:method name="*" propagation="REQUIRED"/> </tx:attributes> </tx:advice> </beans>

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值