zoukankan      html  css  js  c++  java
  • shiro自定义Realm授权时hibernate事务报错

    问题:

    将shiro框架与ssh框架整合后,在自定义的Realm中注入Dao层,但进行授权时,hibernate框架抛异常

    Could not obtain transaction-synchronized Session for current thread

    无法为当前线程获取事务同步的会话

    解决方法:

    在web.xml中,将shiro核心过滤器的位置放在hibernate扩大session范围的过滤器后边

     1 <!-- 整合shiro -->
     2 <filter>
     3     <filter-name>shiroFilter</filter-name>
     4     <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
     5 </filter>
     6 
     7 
     8 <!-- 扩大session作用范围,解决hibernate延迟加载 注意: 必须在struts的filter之前调用 -->
     9 <filter>
    10     <filter-name>openSessionInView</filter-name>
    11     <filter-class>org.springframework.orm.hibernate5.support.OpenSessionInViewFilter</filter-class>
    12 </filter>
    13 
    14 
    15 <!-- 只需保证filter-mapping的位置即可 -->
    16 <filter-mapping>
    17     <filter-name>openSessionInView</filter-name>
    18     <url-pattern>/*</url-pattern>
    19 </filter-mapping>
    20 <filter-mapping>
    21     <filter-name>shiroFilter</filter-name>
    22     <url-pattern>/*</url-pattern>
    23 </filter-mapping>
  • 相关阅读:
    css(一)
    Html table
    Html
    jQuery事件和效果
    jQuery基础
    ajax和http状态码
    点击数组选中某一项,存入数组,再次点击删除
    单行两行,多余显示省略号
    git的使用
    产生滚动效果
  • 原文地址:https://www.cnblogs.com/xiaoyao-lxy/p/7637613.html
Copyright © 2011-2022 走看看