测试shiro session缓存时间过短

master
星期八 6 years ago
parent f119569166
commit 6fa176c3a6
  1. 6
      src/main/java/com/lq/cms/web/IndexController.java
  2. 8
      src/main/resources/spring/spring-shiro.xml
  3. 5
      src/main/webapp/WEB-INF/views/jsp/cms/sys/user/index.jsp

@ -43,7 +43,7 @@ import java.util.HashMap;
@RequestMapping("/cms")
public class IndexController {
private static Logger logger = Logger.getLogger(IndexController.class);
private static Logger LOGGER = Logger.getLogger(IndexController.class);
@Autowired
private SysResourceService sysResourceService;
@ -53,6 +53,10 @@ public class IndexController {
@RequestMapping(value = {"/index",""})
public ModelAndView toCmsIndix(ModelAndView modelAndView, HttpServletRequest request){
Subject subject=SecurityUtils.getSubject();
Session session = subject.getSession();
LOGGER.info("===================");
LOGGER.info("sessionID:"+session.getId());
LOGGER.info("sessionTimeOut:"+session.getTimeout());
SysUser sysUser=(SysUser) subject.getPrincipal();
List<MenusComposite> list = null;
if (subject.hasRole("admin")) {

@ -29,7 +29,7 @@
<bean id="sessionDAO" class="com.lq.code.cache.RedisSessionDao">
<constructor-arg ref="redisTempale"/>
<constructor-arg value="30000000"/>
<constructor-arg value="7200"/>
</bean>
<!-- 配置需要向Cookie中保存数据的配置模版 -->
@ -49,13 +49,13 @@
class="org.apache.shiro.web.session.mgt.DefaultWebSessionManager">
<property name="sessionIdUrlRewritingEnabled" value="false" />
<!-- 定义的是全局的session会话超时时间,此操作会覆盖web.xml文件中的超时时间配置 -->
<!-- <property name="globalSessionTimeout" value="1800000"/>-->
<property name="globalSessionTimeout" value="3600000"/>
<!-- 删除所有无效的Session对象,此时的session被保存在了内存里面 -->
<property name="deleteInvalidSessions" value="false"/>
<!-- 定义要使用的无效的Session定时调度器 -->
<!-- <property name="sessionValidationScheduler" ref="sessionValidationScheduler"/>-->
<property name="sessionValidationScheduler" ref="sessionValidationScheduler"/>
<!-- 需要让此session可以使用该定时调度器进行检测 -->
<!--<property name="sessionValidationSchedulerEnabled" value="true"/>-->
<property name="sessionValidationSchedulerEnabled" value="true"/>
<!-- 定义Session可以进行序列化的工具类 -->
<property name="sessionDAO" ref="sessionDAO"/>
<!-- 所有的session一定要将id设置到Cookie之中,需要提供有Cookie的操作模版 -->

@ -33,7 +33,8 @@
{field:'lastLoginTimeStr',title:'最后登录时间',width:150},
{field:'email',title:'电子邮件',width:150},
{field:'imgUrl',title:'头像',width:50,formatter:function(value,row,index){
return "<img src=\"${ctx}/loadFile/"+value+"\" style=\"width: 30px;height: 30px;border-radius:5px\">";
var html = '<a href="${ctx}/loadFile/'+value+'" target="_blank"><img src="${ctx}/loadFile/'+value+'" style="width: 30px;height: 30px;border-radius:5px"></a>';
return html;
}},
/* formatter 不能重复field,否则会失效**/
{field:'editId',title:'编辑',width:100,formatter:function (value,row,index) {
@ -50,6 +51,7 @@
handler: function(){openEdit('新增',null)}
}]
});
});
</script>
</head>
@ -59,6 +61,7 @@
</body>
<script type="text/javascript">
function openEdit(title,id) {
var url='edit';
if(id!=null){

Loading…
Cancel
Save