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. 定制UVM Messages(参考)

    UVM的Messages机制有些时候很繁琐,很多时候希望能够在UVM messages的基础上做一些个人化的订制,这里给出来一个找到的例子作为参考. my_macros.sv:    `define ...

  2. 移动web——bootstrap媒体对象

    基本模板 1.这些组件都具有在文本内容的左或右侧对齐的图片(就像博客评论或 Twitter 消息等) <div class="media"> <div class ...

  3. Git 学习笔记(W,I,P)

    /*********************** 个人知识水平有限 有任何错误请尽情指出!!谢谢啦 我的Github 求粉 ミ ゚Д゚彡 ***********************/ 参考教程:廖 ...

  4. 计组_IEEE754_练习题

    IEEE754   阶码:移码:尾数:原码 一个规格化的32位浮点数x的真值可表示为:          x=(-1)^s×(1. M) × 2^(E-127)       e=E-127 其中尾数域 ...

  5. 最快的 Python Web 框架入门

    速度比较 框架 实现基础 每秒请求数 平均时间 Sanic Python 3.5 + uvloop 30,601 3.23ms Wheezy gunicorn + meinheld 20,244 4. ...

  6. JAVA通用工具类

    1.异常验证框架 框架1:com.google.common.base.Preconditions 框架2:org.apache.commons.lang.Validate 框架3:org.apach ...

  7. 【python】详解numpy库与pandas库axis=0,axis= 1轴的用法

    对数据进行操作时,经常需要在横轴方向或者数轴方向对数据进行操作,这时需要设定参数axis的值: axis = 0 代表对横轴操作,也就是第0轴: axis = 1 代表对纵轴操作,也就是第1轴: nu ...

  8. c++/c DEBUG宏

    #cat log_debug.h #ifdef DEBUG int log_debug(const char *format, ...); #else int log_debug(const char ...

  9. 刽子手游戏(Hangman Judge, UVa 489)

    刽子手游戏其实是一款猜单词游戏,游戏规则是这样的:计算机想一个单词让你猜,你每次可以猜一个字母.如果单词里有那个字母,所有该字母会显示出来:如果没有那个字母,则计算机会在一幅“刽子手”画上填一笔.这幅 ...

  10. vmware 15安装破解及使用教程

    VMware Workstation Pro15虚拟机破解版(序列号+安装教程) VMware15已经推出,根据版本号名为VMware Workstation Pro 15是一款强大好用的桌面虚拟机软 ...