
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、spring3.0mvc和hibernate基于annotation注解的整合 首先web.xml xml代码 ?xml version="1.0" eoding="utf-8"? web-app xms:xsi="/2001/xmlschema-instance" xmlns=" xmlns:web=" xsi:schemaloion=" ="webapp_id" version="2.5" display-name hiberna
2、teaspringmvc /display-name contt-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 !- this is 'spring' n
3、ame for your spring-servlet.xml - servlet-name spring /servlet-name servlet-class org.springframework.web.servlet.diserservlet /servlet-class load-on-startup 1 /load-on-startup /servlet servlet-map servlet-name spring /servlet-name url-pattern *.xl /url-pattern /servlet-mapping welcome-list welcome-
4、file index.html /welcome-file welcome-file index.htm /welcome-file welcome-file index.jsp /welcome-file welcome-file default.html /welcome-file welcome-file default.htm /welcome-file welcome-file default.jsp /welcome-file /welcome-file-list /web-app 然后是applicationcontext.xml xml代码 ?xml version="
5、;1.0" encoding="utf-8"? beans xmlns="/schema/beans" xmlns:xsi="/2001/xmlschema-instance" xmlns:context="/schema/context" xmlns:tx="/schema/tx"
6、 xmlns:jdbc="/schema/jdbc" xmlns:p="/schema/p" xsi:schemalocation="/schema/beans /schema/beans/spring-beans-3.0.xsd /schema/contex
7、t /schema/context/spring-context-3.0.xsd /schema/tx /schema/tx/spring-tx-3.0.xsd /schema/jdbc /schema/jdbc/spring-jdbc-3.0.xsd" default-autowire="
8、;byname" default-lazy-init="ue" !- this pack must include xxx-servlet.xml's pack. - context:component-scan base-package="org.xlaohe1" / bean id="datasource" "org.springframework.jdbc.datasource.drivermanagerdatasource" property name="driverclassn
9、ame" value="com.mysql.jdbc.driver" / property name="url" value="jdbc:mysql:/localhost:3306/test" / property name="username" value="root" / property name="password" value="root" / /bean bean id="sessionfactory" "
10、;org.springframework.o.hibernate3.annotation.annotationsessionfactorybean" property name="datasource" ref="datasource" / !- 这几句在spring hibernate的注解整合中可以不需要 由于下面的2就是扫描指定路劲下的实体举行映射 - !- 1= - property name="namingstrategy" bean "org.hibernate.cfg.improvnamingstra
11、tegy" / /property property name="annotatedclasses" !- the must have. before this is mapping,now is entity - list value org.xlaohe1.model.user /value /list /property !- 1= - property name="hibernateproperties" props prop key="hibernate.dialect" org.hibernate.dialect
12、.mysqldialect /prop prop key="hibernate.show_sql" false /prop prop key="vider_class" org.hibernate.cache.ehcacheprovider /prop prop key="hibernate.cache.use_query_cache" false /prop prop key="hibernate.jdbc.batch_size" 50 /prop prop key=&quo
13、t;hibernate.cache.use_second_level_cache" false /prop /props /property !- 2= - !- 自动扫描指定位置下的实体文件举行映射 - property name="packagestoscan" value="org.xlaohe1.model" / !- 2= - /bean bean id="transactionmanager" "org.springframework.orm.hibernate3.hibernatetransactio
14、nmanager" property name="sessionfactory" ref="sessionfactory" / /bean tx:annotation-driven transaction-manager="transactionmanager" / /beans spring-serlvet.xml xml代码 ?xml version="1.0" encoding="utf-8"? beans xmlns="http:/www.springframewor
15、/schema/beans" xmlns:context="/schema/context" xmlns:p="/schema/p" xmlns:mvc="/schema/mvc" xmlns:xsi="/2001/xmlschema-instance" xsi:schemalocation=
16、"/schema/beans /schema/beans/spring-beans-3.0.xsd /schema/context /schema/context/spring-context.xsd /schema/mvc /schema/
17、mvc/spring-mvc-3.0.xsd" !- 对web包中的全部类举行扫描,以完成bean创建和自动依靠注入的功能 - context:component-scan base-package="org.xlaohe1.web"/ !-启动spring mvc的注解功能,完成哀求和注解pojo的映射 bean "org.springframework.web.servlet.mvc.annotation.annotationmethodhandleradapter"/ - mvc:annotation-driven/ !- 对模型视图名称的解析,即在模型视图名称添加前后缀 bean "org.springframework.web.servlet.view.internalresourceviewresolver" p:prefix="/web-inf/jsp/" p:suffix=".jsp"/ - bean id="viewresolver" "org.springframework.web.servlet.
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 如何制定有效的复习计划试题及答案
- 软件设计师考试实践项目的价值与经验总结试题及答案
- 软件设计师考试全方位解析及试题与答案
- 机电工程团队协作考核试题及答案
- 机电工程教材更新信息试题及答案
- 2024年农产品加工专用设备资金筹措计划书代可行性研究报告
- 探索西方政治制度与人文关怀的结合试题及答案
- 软件设计师团队合作试题及答案
- 机电工程中的自动控制理论试题及答案
- 软件设计师考试细节把控试题及答案
- 上海市建平西学校2025年八年级数学第二学期期末经典试题含解析
- 壁挂炉销售合同协议书
- 2025年04月高等教育自学考试《00034社会学概论》试题
- 北京小升初试题及答案
- 北京市事业单位退役大学生士兵定向招聘笔试真题2024
- 2025安全生产月主题宣讲课件十:主要负责人安全公开课
- 大数据在医疗领域的应用研究与实践案例分享
- 大学生职业规划大赛《服装与服饰设计专业》生涯发展展示
- 2025年高考语文备考之古诗文名句名篇默写(共80题含答案)
- T-CCMA 0113-2021 高空作业车 检查与维护规程
- 社会学概论知识点梳理与复习指南
评论
0/150
提交评论