1、applicationContext.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:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
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">
<!-- 扫描类包,将标注Spring注解的类自动转化Bean,同时完成Bean的注入 -->
<context:component-scan base-package="com.shxt.*"/>
<!-- 配置数据源 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close"
p:driverClassName="com.mysql.jdbc.Driver"
p:url="jdbc:mysql://localhost:3306/test"
p:username="root"
p:password="root" />
<!-- 配置Jdbc模板 -->
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"
p:dataSource-ref="dataSource" />
<!-- 配置事务管理器 -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
p:dataSource-ref="dataSource" />
<!-- 通过AOP配置提供事务增强,让service包下所有Bean的所有方法拥有事务 -->
<aop:config proxy-target-class="true">
<aop:pointcut id="serviceMethod"
expression=" execution(* com.baobaotao.service..*(..))" />
<aop:advisor pointcut-ref="serviceMethod" advice-ref="txAdvice" />
</aop:config>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*" />
</tx:attributes>
</tx:advice>
</beans>
2.springmvc-servlet.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: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">
<!-- 扫描web包,应用Spring的注解 -->
<context:component-scan base-package="com.shxt.web"/>
<!-- 配置视图解析器,将ModelAndView及字符串解析为具体的页面 -->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:viewClass="org.springframework.web.servlet.view.JstlView"
p:prefix="/WEB-INF/jsp/"
p:suffix=".jsp" />
</beans>
3.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">
<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>
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>3</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
</web-app>
分享到:
相关推荐
定时器的配置文件(两种方式:springmvc自带定时,Quartz与spring结合的定时)
java 配置文件:SpringMVC核心配置文件示例
SpringMVC配置文件 SpringMVC配置文件 SpringMVC配置文件
springmvc + spring + mybatis + maven整合配置文件
springmvc 配置文件 纯配置文件 主要供自己使用
spring framework入门(11):springmvc简易环境搭建 博客:https://blog.csdn.net/u010476739/article/category/7077919
SpringMVC精品资源--优雅整合SSM框架:SpringMVC + Spring + MyBatis(图书预约
spring+mybatis+springmvc maven框架,单模块,导入就可以使用,里面有一个user的增删查改,大家拿来修改就可以使用
SpringMVC精品资源--手把手教你整合最优雅SSM框架:SpringMVC + Spring + MyBatis
spring-mvc:springmvc源码学习
SpringMVC精品资源--手把手教你整合最简洁的SSM框架:SpringMVC + Spring + MyBatis
项目名称:商品信息显示系统 使用技术:Springmvc+spring+mybatis+Layui 实现功能: 1、完成ssm+layui的搭建整合 2、完成商品的分页展示 特点:将后台mysql数据显示在layui页面上
SpringMVC所有jar包和配置文件可以快速配置springmvc项目
基于ssm的毕业设计(论文)管理系统:springmvc、spring、mybatis.zip
SpringMVC Spring MyBatis 框架整合需要的jar包 配置文件 工具类
spring springmvc jpa配置文件 内容详细简单易懂 可直接使用
SpringMVC一些配置文件的demo
ssm项目配置文件(spring,mybatis,springmvc):idea2020 maven-web项目,有所有的配置文件的基础配置,适合任何web项目直接使用
Spring4.05 Mybatis3.2.7 SpringMVC logback的maven配置demo