第一種方式:
1. 使用 @Controller 注解而不是 @RestController
2.方法上不要加 @ResponseBody 然后直接返回你要去的頁面 比如
return "views/home";
這樣頁面會跳轉到你要去的 頁面。但是地址欄的請求是不變的。
第二種方式:
1. 使用ajax請求,在成功的方法里執行新的請求
$.ajax({ url: $.contextPath() + "/signOut", type: 'get', async: false, cache: false, contentType: 'application/json', dataType: 'json', success: function() { window.location.href="/login"; }, error: function() { commonAlert('出現了一點小問題','error'); } });
此時將執行新的請求,重定向到你的Controller里