过期跳转登录页

master
zengwh 5 years ago
parent 4d682f7f82
commit bb0af95c6b

@ -16,6 +16,7 @@ import org.apache.cxf.endpoint.Client;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
@ -42,7 +43,11 @@ public class UrlInterceptor implements HandlerInterceptor {
String resultString = HttpClientTool.doPost(requestUrl, params);
String code = JSONArray.toJSONString(JSON.parseObject(resultString).get("code"));
if ("200".equals(code)) {
response.sendRedirect(POWER_URLHEAD + "/login");
if (isAjaxRequest(request)) {
response.setHeader("sessionstatus", "timeout");
} else{
response.sendRedirect(POWER_URLHEAD + "/login");
}
return false;
}
//更新session
@ -60,6 +65,20 @@ public class UrlInterceptor implements HandlerInterceptor {
}
return true;
}
/**
* ajax
* @param request
* @return
*/
private boolean isAjaxRequest(HttpServletRequest request) {
String header = request.getHeader("X-Requested-With");
if (header != null && "XMLHttpRequest".equals(header)) {
return true;
}else {
return false;
}
}
}

@ -57,6 +57,6 @@
<script src="${path}/static/bootstrap-3.3.7/bower_components/bootstrap/dist/js/fileinput.min.js"></script>
<script type="text/javascript" src="${path}/static/js/hospitalCommom/pinying.js"></script>
<script type="text/javascript" src="${path}/static/js/comm.js?t=2020-10-29"></script>
<script type="text/javascript" src="${path}/static/js/comm.js?t=2020-11-09"></script>
<script type="text/javascript" src="${path}/static/js/md5.js"></script>
<input type="hidden" id="userId" value="${CURRENT_USER.userId}">

@ -812,7 +812,7 @@
</div>
</div>
</body>
<script src="${path}/static/js/beHospList/beHospList.js?time=2020-11-03"></script>
<script src="${path}/static/js/hospitalCommom/hospitalCommom.js?time=2020-11-03"></script>
<script src="${path}/static/js/beHospList/beHospList.js?time=2020-11-09"></script>
<script src="${path}/static/js/hospitalCommom/hospitalCommom.js?time=2020-11-09"></script>
<script src="${path}/static/js/hospitalLoadPdf/loadPdf.js?time=2020-10-16"></script>
</html>

@ -1,4 +1,5 @@
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" %>

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set value="${pageContext.request.contextPath}" var="path" scope="page"/>
<html>
@ -13,42 +14,52 @@
<%@ include file="/WEB-INF/jspf/comm.jspf" %>
<script type="text/javascript" src="${path}/static/js/menu.js?time=2020-09-14_1"></script>
<style>
.hidden-xs{
.hidden-xs {
max-width: 200px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.indexSelected{
.indexSelected {
background-color: #1E2D3B;
color: #fff!important;
color: #fff !important;
}
.modleSelected {
font-weight: bold;
font-size: 16px;
}
.sidebar-mini:not(.sidebar-collapse) #indexTreeMenu:hover{
.sidebar-mini:not(.sidebar-collapse) #indexTreeMenu:hover {
overflow-y: auto;
overflow-x: hidden;
}
.sidebar-mini:not(.sidebar-collapse) #indexTreeMenu::-webkit-scrollbar{
.sidebar-mini:not(.sidebar-collapse) #indexTreeMenu::-webkit-scrollbar {
display: none;
}
.navbar-custom-menu{
padding-right:17px;
.navbar-custom-menu {
padding-right: 17px;
}
.row-fluid{
.row-fluid {
overflow-y: hidden;
}
.sidebar-mini.sidebar-collapse #indexTreeMenu li>a{
.sidebar-mini.sidebar-collapse #indexTreeMenu li > a {
height: 44px;
}
.sidebar-mini.sidebar-collapse #indexTreeMenu .pull-right-container{
margin-top:0;
.sidebar-mini.sidebar-collapse #indexTreeMenu .pull-right-container {
margin-top: 0;
}
.sidebar-mini.sidebar-collapse #indexTreeMenu .modleSelected .pull-right-container{
.sidebar-mini.sidebar-collapse #indexTreeMenu .modleSelected .pull-right-container {
margin-top: -6px;
}
@media (min-width: 768px) {
.sidebar-mini:not(.sidebar-mini-expand-feature).sidebar-collapse .sidebar-menu > li:hover > a > span:not(.pull-right), .sidebar-mini:not(.sidebar-mini-expand-feature).sidebar-collapse .sidebar-menu > li:hover > .treeview-menu {
display: block !important;
@ -57,7 +68,11 @@
left: 50px;
}
}
.home-menu:hover .dropdown-menu {display: block;}
.home-menu:hover .dropdown-menu {
display: block;
}
.sidebar {
padding-bottom: 0;
}
@ -66,15 +81,14 @@
var path = "${path}";
</script>
</head>
<script type="text/javascript">
function uniq(array){
function uniq(array) {
var temp = [];
var index = [];
var l = array.length;
for(var i = 0; i < l; i++) {
for(var j = i + 1; j < l; j++){
if (array[i] === array[j]){
for (var i = 0; i < l; i++) {
for (var j = i + 1; j < l; j++) {
if (array[i] === array[j]) {
i++;
j = i;
}
@ -84,70 +98,71 @@
}
return temp;
}
$(function () {
function ajaxJsonFun() {
//拥有的功能
var str = "";
//所属科室
var depts = "";
if (${menuList == null}){
if (${menuList == null}) {
$('#exampleModal').modal({
backdrop: 'static',//backdrop 为 static 时,点击模态对话框的外部区域不会将其关闭。
keyboard: false,//keyboard 为 false 时,按下 Esc 键不会关闭 Modal。
show: true//弹出对话框
});
return ;
}else if (${menuList != null}) {
return;
} else if (${menuList != null}) {
var menuList = <%=session.getAttribute("menuList")%>;//${menuList == null} ? window.location.href = "login.jsp" :${menuList};
if (menuList != "") {
if (menuList.code == 100) {
var roleId = '';
var list = menuList.extend.list;
if (list != null) {
if (list != null && list.length > 0) {
var sysUL;
var count = 100000;
var deptArr = [];
roleId = list[0].roleId;
//roleId等于0或-100不受科室限制
if(roleId != -100 && roleId != 0) {
if (roleId != -100 && roleId != 0 && list[0].deptCode != 1) {
for (var i = 0; i < list.length; i++) {
if (list[i].deptCode != '') {
deptArr.push(list[i].deptCode);
}
}
}else{
} else {
deptArr = [];
}
var deptList = '';
if(deptArr != ''){
if (deptArr != '') {
deptList = uniq(deptArr);
}
var depts = '';
if(deptList != ''){
if (deptList != '') {
for (var i = 0; i < deptList.length; i++) {
if(i != deptList.length-1){
if (i != deptList.length - 1) {
depts += deptList[i] + ",";
}else{
} else {
depts += deptList[i];
}
}
}
localStorage.setItem($("#userId").val()+"_depts",depts);
localStorage.setItem($("#userId").val() + "_depts", depts);
for (var i = 0; i < list.length; i++) {
if (list[0].deptId == list[i].deptId) {
if (list[i].methodParent != 0 && (list[i].menuUrl == "#" || list[i].menuUrl == "" || list[i].menuUrl == null)) {
var mulLi = '';
if(list.length > 1 && i == 1){
if (list.length > 1 && i == 1) {
mulLi = newLiFun(true);
}else{
} else {
mulLi = newLiFun(false);
}
var mulA = '';
//是第一个默认选中
if(i == 1){
mulA = newAFun(list[i].menuName, list[i].menuIcon,true);
}else{
mulA = newAFun(list[i].menuName, list[i].menuIcon,false);
if (i == 1) {
mulA = newAFun(list[i].menuName, list[i].menuIcon, true);
} else {
mulA = newAFun(list[i].menuName, list[i].menuIcon, false);
}
mulLi.append(mulA);
var menuAUL = newUlFun();
@ -168,24 +183,24 @@
if (str.indexOf("undefined") != -1) {
str = "";
}
if(count > list[j].methodSort){
if (count > list[j].methodSort) {
count = list[j].methodSort;
sysUL = path + list[j].menuUrl + "?num=" + str + "&depts=" + depts;
}
var menuALi = '';
var menuUrl = path + list[j].menuUrl + "?num=" + str + "&depts=" + depts;
if(i == 1){
if (i == 1) {
//默认选中第一个
faultModleSelected = true;
defaultUrl = menuUrl;
}
menuALi = newAliFun(list[j].menuName, list[j].menuIcon, menuUrl,faultModleSelected,list[j].menuId);
menuALi = newAliFun(list[j].menuName, list[j].menuIcon, menuUrl, faultModleSelected, list[j].menuId);
menuAUL.append(menuALi);
mulLi.append(menuAUL);
}
}
}
$("#iFrame1").prop('src',sysUL);
$("#iFrame1").prop('src', sysUL);
$('#indexTreeMenu').append(mulLi);
}
}
@ -236,26 +251,33 @@
</li>
<li class="user user-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<img src="${path}/static/bootstrap-3.3.7/bower_components/bootstrap/dist/img/user2-160x160.jpg" class="user-image"
<img src="${path}/static/bootstrap-3.3.7/bower_components/bootstrap/dist/img/user2-160x160.jpg"
class="user-image"
alt="User Image">
<c:choose>
<c:when test="${CURRENT_USER.remark == '' || CURRENT_USER.remark == null || CURRENT_USER.remark == 'null'}">
<c:choose>
<c:when test="${CURRENT_USER.userPosition != null && CURRENT_USER.userPosition != '' && CURRENT_USER.userPosition != 'null'}">
<span class="hidden-xs" title="${CURRENT_USER.userPosition}">${CURRENT_USER.userPosition}</span>
<div class="hidden-xs"
title="${CURRENT_USER.userPosition}">${CURRENT_USER.userPosition}</div>
</c:when>
<c:otherwise>
<span class="hidden-xs" title="${CURRENT_USER.userName}">${CURRENT_USER.userName}</span>
<div class="hidden-xs"
title="${CURRENT_USER.userName}">${CURRENT_USER.userName}</div>
</c:otherwise>
</c:choose>
</c:when>
<c:otherwise>
<c:choose>
<c:when test="${CURRENT_USER.userPosition != null && CURRENT_USER.userPosition != '' && CURRENT_USER.userPosition != 'null'}">
<span class="hidden-xs" title="${CURRENT_USER.userPosition}(${CURRENT_USER.remark})">${CURRENT_USER.userPosition}(${CURRENT_USER.remark})</span>
<div class="hidden-xs"
title="${CURRENT_USER.userPosition}(${CURRENT_USER.remark})">${CURRENT_USER.userPosition}(${CURRENT_USER.remark})
</div>
</c:when>
<c:otherwise>
<span class="hidden-xs" title="${CURRENT_USER.userName}(${CURRENT_USER.remark})">${CURRENT_USER.userName}(${CURRENT_USER.remark})</span>
<div class="hidden-xs"
title="${CURRENT_USER.userName}(${CURRENT_USER.remark})">${CURRENT_USER.userName}(${CURRENT_USER.remark})
</div>
</c:otherwise>
</c:choose>
</c:otherwise>
@ -263,7 +285,8 @@
</a>
</li>
<li class="home-menu">
<a href="${POWER_URLHEAD}/gatewayPage"><i class="fa fa-home" style="font-size: 20px" title="点击返回主页"></i></a>
<a href="${POWER_URLHEAD}/gatewayPage"><i class="fa fa-home" style="font-size: 20px"
title="点击返回主页"></i></a>
<ul class="dropdown-menu" role="menu">
<li><a href="${POWER_URLHEAD}/gatewayPage">返回主页</a></li>
<li class="divider"></li>
@ -350,7 +373,8 @@
<div class="content-wrapper">
<iframe style="width:100%; overflow-x:hidden;overflow-y:scroll" id="iFrame1" name="iFrame1" frameborder="0"></iframe>
<iframe style="width:100%; overflow-x:hidden;overflow-y:scroll" id="iFrame1" name="iFrame1"
frameborder="0"></iframe>
</div>
<footer class="main-footer">
<div class="pull-right">

@ -378,4 +378,14 @@ function getPreMonthDay(date, monthNum) {
}
var t2 = year2 + '-' + month2 + '-' + day2
return t2
}
}
$.ajaxSetup({
contentType:"application/x-www-form-urlencoded;charset=utf-8",
complete:function(XMLHttpRequest,textStatus){
var sessionstatus=XMLHttpRequest.getResponseHeader("sessionstatus"); //通过XMLHttpRequest取得响应头sessionstatus
if(sessionstatus=="timeout"){
//如果超时就处理 ,指定要跳转的页面
top.location.replace(path+"/login");
}
}
});

Loading…
Cancel
Save