From 7716a7877ef93857a028ea2ffef6f73568daed36 Mon Sep 17 00:00:00 2001 From: zwzw1219 Date: Sun, 15 Oct 2017 17:43:54 +0800 Subject: [PATCH] 1 --- src/main/resources/public/login.html | 9 +++++---- src/main/resources/static/js/jq.js | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/resources/public/login.html b/src/main/resources/public/login.html index 408a026..df5f0c0 100644 --- a/src/main/resources/public/login.html +++ b/src/main/resources/public/login.html @@ -40,7 +40,7 @@ var user = loginInfo(); if (user != "") { - location.href = '/'; + location.href = '/index.html'; } function login(obj) { @@ -54,10 +54,11 @@ } else { $.ajax({ type : 'post', - url : '/sys/login', + url : '/login', data : $("#login-form").serialize(), - success : function() { - location.href = '/'; + success : function(data) { + localStorage.setItem("token", data.token); + location.href = '/index.html'; }, error : function(xhr, textStatus, errorThrown) { var msg = xhr.responseText; diff --git a/src/main/resources/static/js/jq.js b/src/main/resources/static/js/jq.js index bdeb82b..4e4c801 100644 --- a/src/main/resources/static/js/jq.js +++ b/src/main/resources/static/js/jq.js @@ -1,5 +1,8 @@ $.ajaxSetup({ cache : false, + headers : { + "token" : localStorage.getItem("token") + } error : function(xhr, textStatus, errorThrown) { var msg = xhr.responseText; var response = JSON.parse(msg);