将Shiro作为应用的权限基础五:SpringMVC+ApacheShiro+JPAhibernate整合配置_第1页
将Shiro作为应用的权限基础五:SpringMVC+ApacheShiro+JPAhibernate整合配置_第2页
将Shiro作为应用的权限基础五:SpringMVC+ApacheShiro+JPAhibernate整合配置_第3页
将Shiro作为应用的权限基础五:SpringMVC+ApacheShiro+JPAhibernate整合配置_第4页
将Shiro作为应用的权限基础五:SpringMVC+ApacheShiro+JPAhibernate整合配置_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、将Shiro作为应用的权限基础 五:SpringMVC+Apache Shiro+JPA (hibernate)整合配置 配置 web.xml,applicationContext.xml, spring-mvc.xml,applicationContext-shiro.xml ,而且 都有详细的说明。 web.xml是web项目最基本的配置文件,看这个配置,可以快速知道 web项目使用什 么框架,它就像一个面板,切入我们想用的插件。 applicationContext.xml是spring的基本配置,主要配置数据源、 JPA实体管理器工厂、 事务; spring-mvc.xml 是 Spr

2、ingMVC 的配置; applicationContext-shiro.xml 是 shiro 的配置,主要酉己置 securityManager、 shiroFilter; web.xml param-name param-value contextConfigLocation classpath*:applicationContext*.xml org.springframework.web.util.IntrospectorCleanupListener org.springframework.web.context.ContextLoaderListener characterEnc

3、odingFilter org.springframework.web.filter.CharacterEncodingFilter encoding UTF-8 forceEncoding true characterEncodingFilter /* hibernateFilter org.springframework.orm.jpa.support .OpenEntityManagerInViewFilter / filter-class filter-mapping filter-name hibernateFilter /* filter-name filter-class / f

4、ilter-mapping !- 必须对应 applicationContext.xml - url-pattern /* !- webAppRootKey spring_springmvc_jpa.root log4jConfigLocation classpath:perties shiroFilter / filter-name filter-class org.springframework.web.filter.DelegatingFilterProxy / filter-class targetFilterLifecycle true / param-value

5、/ init-param filter-mapping shiroFilter / filter-name !- 把log4j 的默认配置文件(perties) 目录下.这种方式是log4j 配置Log4j 通常是 /web-inf/classes 无须其他配置。 缺点就是无法灵活的通过配置文件来指定 perties webAppRootKey 是log4j 在容器中的唯一标识,缺省为 放在 classpath 中, 默认配置方式, 的文件位置 webapp.root 这里 filter-name 中定义的 org.springframework.web.u

6、til.Log4jConfigListener - dispatcherServlet org.springframework.web.servlet.DispatcherServlet contextConfigLocation classpath:spring-mvc.xml / param-value 1 dispatcherServlet / login.jsp !- Servlet2.5 中可直接在此处执行 Servlet 应用,如 servlet/InitSystemParamServlet - !- 这里使用了 SpringMVC 提供的 标签, 实现了首页隐藏的目的,详见spr

7、ing-mvc.xml - !- login.jsp - applicationContext.xml bean id =dataSource” class = com.jolbox.bonecp.BoneCPDataSource” bean id =txManager class = org.springframework.orm.jpa.JpaTransactionManager1 = close destroy-method _ property name =driverClass property name =jdbcUrl property name =username proper

8、ty name = password value value =$jdbc.driverClassName) = $jdbc.url) / / value value =$jdbc.username) =$jdbc.password) bean id = entityManagerFactory org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean class property name =dataSource ref =dataSource / / ref = hibernateJpaVendorAdapter

9、/ property name =jpaProperties prop key thread = hibernate.currentsessioncontextclass prop key = hibernate.hbm2ddl.auto update / prop key = hibernate.show_sql false prop false / prop prop key =hibernate.ejb.naming_strategy org.hibernate.cfg.ImprovedNamingStrategy / prop bean id =hibernateJpaVendorAdapter org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter property name = entityManagerFactory ref = entityManagerFactory spring-mvc.xml !-默认访问跳转到登录页面,即定义无 Controller 的pathview 直接映射- !

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论