之前採取ajax進行請求操作,由於使用了攔截器,session中token過期後,ajax請求返回html格式的數據,很不方便。
後來逐漸自己測試發現,除了ajax之外,其他幾種操作方式暫未出現問題。
不會出現攔截後返回html登錄頁的操作方式:
1、form表單提交。
2、html中的標籤,如a標籤。
3、window.location.href
所以我們只要保證以上三種之一就可以避免攔截後返回html格式文件的現象發生。
<a class="btn btn-xs btn-default "
th:if="${productList.status==1}"
th:onclick="consureEdit([[${productList.id}]]);">
<span class="glyphicon glyphicon-trash" >失效</span>
</a>
js
function consureEdit(productId){
console.log("consureEdit");
layer.confirm('溫馨提示:<br>點擊確認後,會將此設備失效不可用!<br>您確定繼續進行此操作嗎?', {
btn: ['確定','取消'] //按鈕
}, function(){
console.log("確定");
window.location.href="xxxxxx";
}, function(){
console.log("取消");
});
}
更改完成後,重啓項目去除session,再在歷史頁面上直接請求。