Extjs5开发学习-27-服务端web,spring,hibernate配置文件的加入

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

Extjs5开发学习-27-服务端web,spring,hibernate配置文件的加入我们前面创建项目的时候是一个javawebproject,现在在项目中需要加入spring,hibernate,sqlserver连接的jar包以及加入配置文件。spring我现在使用的是3.1版本,hibernate使用的是3.0,具体的jar包以及一些附加包,请自行下载后加到工程中。(所有的jar包在我的前一个博客中提供的演示软件中有)一、在javaResources的src中加入一些package。在src目录下建立文件hibernate.cfg.xml和log4j.properties。hibenate的配置文件如下:/application5.01/src/hibernate.cfg.xml(使用的是sqlserver数据库,用其他数据库也可以。)[html]viewplaincopy1.?xmlversion=1.0encoding=UTF-8?2.!DOCTYPEhibernate-configurationPUBLIC-//Hibernate/HibernateConfigurationDTD3.0//EN3.=hibernate.connection.driver_classcom.microsoft.sqlserver.jdbc.SQLServerDriver/property8.propertyname=hibernate.connection.urljdbc:sqlserver://10.211.55.5:1433;databaseName=haiyu/property9.10.propertyname=hibernate.dialectorg.hibernate.dialect.SQLServerDialect/property11.propertyname=hibernate.connection.usernamesa/property12.propertyname=hibernate.connection.password/property13.14.propertyname=hibernate.connection.autocommitfalse/property15.propertyname=format_sqltrue/property16.propertyname=show_sqltrue/property17.18./session-factory19./hibernate-configuration系统日志配置文件:/application5.01/src/log4j.properties。[html]viewplaincopy1.log4j.rootCategory=error,console2.3.log4j.appender.console=org.apache.log4j.ConsoleAppender4.log4j.appender.console.layout=org.apache.log4j.PatternLayout5.log4j.appender.console.layout.ConversionPattern=%-4r[%t]%-5p%c%x-%m%n6.7.log4j.logger.org.hibernate=error8.log4j.logger.org.hibernate.SQL=error9.log4j.logger.com.jfok=error10.log4j.logger.org.springframework=error11.12.#log4j.category.org.hibernate.type=debug二、修改web.xml文件,加入spring的设置。在WEB-INF目录下需要修改web.xml,并加入二个spring的配置文件applicationContext.xml和dispatcherServlet-servlet.xml。web.xml的文件内容:[html]viewplaincopy1.?xmlversion=1.0encoding=UTF-8?2.web-appxmlns:xsi=:schemaLocation=://java.sun.com/xml/ns/javaee/web-app_2_5.xsd5.version=2.5xmlns=!--spring监听器--8.listener9.listener-classorg.springframework.web.context.ContextLoaderListener/listener-class10./listener11.12.!--spring配置文件地址--13.context-param14.param-nameContextConfigLocation/param-name15.param-value16./WEB-INF/applicationContext.xml17./param-value18./context-param19.20.!--Servlets--21.22.!--springMVC,其配置文件为servlet-name-servlet.xml,这里为“dispatcherServlet-servlet.xml”--23.servlet24.servlet-namedispatcherServlet/servlet-name25.servlet-classorg.springframework.web.servlet.DispatcherServlet/servlet-class26.load-on-startup1/load-on-startup27./servlet28.servlet-mapping29.servlet-namedispatcherServlet/servlet-name30.url-pattern*.do/url-pattern31.!--用于匹配/rest/module/remove.do/{id}之类的调用--32.url-pattern/rest/*/url-pattern33./servlet-mapping34.35.!--字符集编码过滤,防止某些乱码--36.37.filter38.filter-nameencodingFilter/filter-name39.filter-classorg.springframework.web.filter.CharacterEncodingFilter/filter-class40.init-param41.param-nameencoding/param-name42.param-valueUTF-8/param-value43./init-param44.init-param45.param-nameforceEncoding/param-name46.param-valuetrue/param-value47./init-param48./filter49.filter-mapping50.filter-nameencodingFilter/filter-name51.url-pattern/*/url-pattern52./filter-mapping53.54.!--Defaultpagetoserve180--55.welcome-file-list56.welcome-file/index.jsp/welcome-file57./welcome-file-list58.session-config59.session-timeout180/session-timeout60./session-config61.62.jsp-config63.jsp-property-group64.url-pattern*.jsp/url-pattern65.trim-directive-whitespacestrue/trim-directive-whitespaces66./jsp-property-group67./jsp-config68.69./web-appapplicationContext.xml的内容:[html]viewplaincopy1.?xmlversion=1.0encoding=UTF-8?2.beansxmlns=:xsi=:p=:tx=:context=:schemaLocation=6.://://://://://:annotation-config/14.context:component-scanbase-package=com.jfok15.!--将控制层排除在外,只扫描生成服务层的DAO层的类--16.context:exclude-filtertype=annotation17.expression=org.springframework.stereotype.Controller/18./context:component-scan19.tx:annotation-driventransaction-manager=transactionManagerproxy-target-class=true/20.21.!--spring用于替换hibernateSessionFactory.java的sessionFactory--22.beanid=sessionFactory23.class=org.sprin

1 / 13
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功