`

spring security deault login & jquery layout 的问题

阅读更多

使用spring security时需要配置默认的登陆页面,就是在session失效或者其它原因需要登陆时的页面。

<http auto-config='true'>
    <intercept-url pattern="/login.jsp*" filters="none"/>
    <intercept-url pattern="/**" access="ROLE_USER" />
    <form-login login-page='/login.jsp'/>
 </http>

 

当使用类似于jquery layout页面框架时就会用登陆页面只显示在页面中某一个部分。

例如:整个页面用/startIndex.do加载mylayout.jsp,  mylayout.jsp中分为上,左(menu),下,右(content),当session失效时,点击左的菜单,右面就会显示login.jsp. 这样是不合理的,

    我一开始的解决方式,是自己写了filter ,但无论是自己写新的filter或才重写spring security的filter,始终首先显示是spring默认的页面。

    其实只需要在login.jsp里加上js跳转就可以,其中两个地方需要注意:

    1. 在login.jsp里直接写js它在session失效时不执行,可以使用jquery中执行:如

$(document).ready(function () { 
		var url = window.parent.document.URL;
		if (url.indexOf("core") != -1) {//只有当在maylayout页面才reload
		window.location.reload("${pageContext.request.contextPath}/login.jsp");
		}
	})

   2. 因为你点击右面菜单时session失败,跳转到登陆页面,当你再次登陆后页面还会回到你点击的地址,这样会有问题,有个技巧就是可以把reload写成整个页面用/startIndex.do,如:

  

$(document).ready(function () { 
        var url = window.parent.document.URL;
         if (url.indexOf("core") != -1) {//只有当在maylayout页面才reload
		window.location.reload("${pageContext.request.contextPath}/startIndex.do");
		}
	})

 

1
0
分享到:
评论

相关推荐

    20190527_settings_deault.zip

    pycharm 配置文件,根据多年的经验总结,分享出来大家一起学习。

    Caravansary:将创作过程变成一个闲置的游戏!

    特征点击通过deault贡献为这个回购加上星号建议功能,模块或帮助发展克隆此仓库创建WPF类库项目参考商队实现ICoreModule 文件夹“模块”中的模块将被自动检测并在应用程序中运行将dll和其他文件打包为.zip 创建任务...

    IDA_WaitBoxEx:IDA WaitBoxEx

    修正: 修复了IDA等待框和主窗口冻结/停顿/挂断问题。 等待框用作主窗口的直接子级; 避免在选择/切换默认窗口时看到奇怪的单独窗口。 工作的“取消”按钮可立即响应用户输入。 启用关闭的“ X”按钮,作为备用的...

    react-app-rewire-less-with-modules:react-app-rewired,支持更少CSS模块

    安装 yarn add react-app-rewire-less-with-modules -D ...与antd一起使用,自定义deault主题,modifyVars覆盖默认值。 const { injectBabelPlugin } = require('react-app-rewired') const rewireLessWi

    watermarking:这是一个使用DWT和SVD进行水印处理的项目

    水印 这是一个使用DWT和SVD进行盲水印的项目。 如何使用? from watermarking import watermarking watermarking = watermarking ()... 可以用参数watermark_path替换deault watermark_path watermarking.watermark

    AnyFormatProtocol:简单安全的 any? 格式化协议

    , deault : T) -&gt; T for example : let int = format ( " 1 " , default : 6 ) ==&gt; 1 let int = format ( nil , default : 6 ) ==&gt; 6 let int = format ( nil ) ==&gt; 0 安装 可通过获得 。 要安装它,只需将以下行...

    Hibernate注释大全收藏

    (7) 定义对应的表(deault 是主表) int length() default 255; (8) 列长度 int precision() default 0; // decimal precision (9) decimal精度 int scale() default 0; // decimal scale (10) decimal长度 ...

Global site tag (gtag.js) - Google Analytics