web.xml

 <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1"> <servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet> <servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping> <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>
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: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.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.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.xsd"
default-init-method="init" default-destroy-method="destroy"> <!-- 导入外部的properties文件 -->
<context:property-placeholder location="classpath:jdbc.properties"/>
<!--<context:annotation-config/>--><!--启用注解扫描--> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"><!--数据源-->
<property name="url" value="${jdbc.url}"/>
<property name="driverClassName" value="${jdbc.driver}"/>
<property name="username" value="${jdbc.name}"/>
<property name="password" value="${jdbc.pass}"/>
</bean> <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.MySQL5Dialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>hbm/User.hbm.xml</value>
<value>hbm/UserDetails.hbm.xml</value>
<value>hbm/Goods.hbm.xml</value>
<value>hbm/GoodDetails.hbm.xml</value>
<value>hbm/BuyCar.hbm.xml</value>
<value>hbm/Order.hbm.xml</value>
<value>hbm/OrderDetails.hbm.xml</value>
</list>
</property>
</bean> <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean> <tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="create*"/>
<tx:method name="query*"/>
<tx:method name="update*"/>
<tx:method name="delete*"/>
</tx:attributes>
</tx:advice> <aop:config>
<!--切面的配置 id表示切面的唯一id,ref表示切面的支持类-->
<aop:pointcut id="CRUDOperate" expression="execution(* com.iotek.homework.service.*.*(..))"/><!--切点( 切入点)-->
<aop:advisor advice-ref="txAdvice" pointcut-ref="CRUDOperate"/>
</aop:config> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate4.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory"/>
</bean> <!--user start-->
<bean id="userDAO" class="com.iotek.homework.dao.UserDAOImpl"/>
<bean id="userService" class="com.iotek.homework.service.UserServiceImpl"/>
<bean id="userController" class="com.iotek.homework.controller.UserController"/>
<!--user end--> <!--userDetails start-->
<bean id="userDetailsDAO" class="com.iotek.homework.dao.UserDetailsDAOImpl"/>
<bean id="userDetailsService" class="com.iotek.homework.service.UserDetailsServiceImpl"/>
<!-- <bean id="userDetailsAction" class="com.iotek.homework.actions.UserDetailsAction"/>-->
<!--userDetails end--> <!--goods start-->
<bean id="goodsDAO" class="com.iotek.homework.dao.GoodsDAOImpl"/>
<bean id="goodsService" class="com.iotek.homework.service.GoodsServiceImpl"/>
<!-- <bean id="goodsAction" class="com.iotek.homework.actions.GoodsAction"/>-->
<!--goods end--> <!--buyCar start-->
<bean id="buyCarDAO" class="com.iotek.homework.dao.BuyCarDAOImpl"/>
<bean id="buyCarService" class="com.iotek.homework.service.BuyCarServiceImpl"/>
<!-- <bean id="buyCarAction" class="com.iotek.homework.actions.BuyCarAction"/>-->
<!--buyCar end--> <!--orders start-->
<bean id="ordersDAO" class="com.iotek.homework.dao.OrdersDAOImpl"/>
<bean id="ordersService" class="com.iotek.homework.service.OrdersServiceImpl"/>
<!-- <bean id="ordersAction" class="com.iotek.homework.actions.OrdersAction"/>-->
<!--orders end--> </beans>
dispatcher-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: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.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd"> <!-- 支持注解 -->
<mvc:annotation-driven />
<!--注解扫描-->
<context:component-scan base-package="com.iotek.homework.controller"/> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/pages/"/>
<property name="suffix" value=".jsp"/>
</bean> <bean id="jsonConvert" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"/> <bean id="stringConvert" class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/plain;charset=UTF-8</value>
</list>
</property>
</bean> <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="jsonConvert"/>
<ref bean="stringConvert"/>
</list>
</property>
</bean> <import resource="classpath:applicationContext.xml"/> <!--静态资源注册-->
<mvc:resources mapping="/css/*" location="/css/"/>
<mvc:resources mapping="/js/*" location="/js/"/>
<mvc:resources mapping="/images/*" location="/images/"/>
</beans>

SpringMVC + hibernate 配置文件的更多相关文章

  1. Maven搭建SpringMVC+Hibernate项目详解 【转】

    前言 今天复习一下SpringMVC+Hibernate的搭建,本来想着将Spring-Security权限控制框架也映入其中的,但是发现内容太多了,Spring-Security的就留在下一篇吧,这 ...

  2. springmvc+hibernate入门-揭开神秘的面纱

            Spring 框架提供了构建 Web 应用程序的全功能 MVC 模块.使用 Spring 可插入的 MVC 架构,可以选择是使用内置的 Spring Web 框架还是 Struts 这 ...

  3. Maven搭建SpringMVC+Hibernate项目详解

    前言 今天复习一下SpringMVC+Hibernate的搭建,本来想着将Spring-Security权限控制框架也映入其中的,但是发现内容太多了,Spring-Security的就留在下一篇吧,这 ...

  4. springMVC用法 以及一个简单的基于springMVC hibernate spring的配置

    替代struts 1  web.xml中配置springmvc中央控制器 <?xml version="1.0" encoding="UTF-8"?> ...

  5. Maven搭建SpringMVC+Hibernate项目详解(转)

    前言 今天复习一下SpringMVC+Hibernate的搭建,本来想着将Spring-Security权限控制框架也映入其中的,但是发现内容太多了,Spring-Security的就留在下一篇吧,这 ...

  6. SpringMVC Hibernate+Spring+Spring MVC+Bootstrap的管理系统实现

    SpringMVC学习系列(12) 完结篇 之 基于Hibernate+Spring+Spring MVC+Bootstrap的管理系统实现 到这里已经写到第12篇了,前11篇基本上把Spring M ...

  7. springMVC+Hibernate配置

    本文描述下 sypro 项目中使用 springMVC+Hibernate配置,初学SpringMVC做下简单整理解. 1.web项目首先我们要使用 web.xml文件将 spring配置引入进来 & ...

  8. 框架篇:Spring+SpringMVC+hibernate整合开发

    前言: 最近闲的蛋疼,搭个框架写成博客记录下来,拉通一下之前所学知识,顺带装一下逼. 话不多说,我们直接步入正题. 准备工作: 1/ IntelliJIDEA的安装配置:jdk/tomcat等..(本 ...

  9. springMvc+hibernate的web application的构建

    闲来没事,想整理下一些知识. 这篇文章是关于spring的web程序的搭建,有什么不对的地方希望大家批评指正. 首先我们要了解什么是spring,这里可能很多大家也都明白,无非是一个管理对象的一个容器 ...

随机推荐

  1. Select2插件ajax方式加载数据并刷新页面数据回显

    今天在优化项目当中,有个要在下拉框中搜索数据的需求:最后选择使用selec2进行开发: 官网:http://select2.github.io/ 演示: 准备工作: 文件需要引入select2.ful ...

  2. iOS - UITableView 单选功能实现

    #import <UIKit/UIKit.h> @interface TestCell : UITableViewCell @property(nonatomic,copy)NSStrin ...

  3. vue项目杂记

    vue项目杂记 文件目录结构 src main.js app.vue package.json webpack_config_dev.js 需要安装的包 1. vue cnpm i vue --sav ...

  4. SAS进阶《深入解析SAS》之对多数据集的处理

    SAS进阶<深入解析SAS>之对多数据集的处理 1. 数据集的纵向串接: 数据集的纵向串接指的是,将两个或者多个数据集首尾相连,形成一个新的数据集. 据集的横向合并: 数据集的横向合并,指 ...

  5. Android基础TOP3_1:纵横屏切换

    在Res下建立layout-port文件夹  为竖屏时加载的界面: 建立layout-land 文件夹 为横屏加载的界面

  6. C# winform启动外部exe后,如何完全阻断父界面接收事件,扩展waitforexit

    公司的系统搭载了好多奇奇怪怪的exe,以前启动exe后,系统还能接着操作.但是后面又提出额外的需求,说是打开外部exe之后,启动exe的父界面要完全不能进行任何操作.当然按常人所想再加一句waitfo ...

  7. IP访问频率限制不能用数组循环插入多个限制条件原因分析及解决方案

    14.IP频率限制不能用数组循环插入多个限制条件原因分析及解决方案: define("RATE_LIMITING_ARR", array('3' => 3, '6' => ...

  8. Oracle Sequence不设置cache参数的几个潜在问题(转载)

    转载于 http://www.uml.org.cn/sjjm/201204065.asp 在Oracle中,我们没有MYSQL和SQL                           Server ...

  9. Python 之scrapy框架58同城招聘爬取案例

    一.项目目录结构: 代码如下: # -*- coding: utf-8 -*- # Define here the models for your scraped items # # See docu ...

  10. 【转载】resolv.conf中search作用

    原文地址:http://www.oliver.ren/linux/387.html reslov.conf中的search主要是用来补全hostname的,有时候域名太长,可以做一个短域名做主机名字, ...