@ResponseBody一定一定要加啊!!!!!!不加的話前臺報錯,後臺警告!!!!前臺:jquery.min.js:2 POST http://172.13.31.75:8080/kuaibeiPro/querySessionId 404 (Not Found)send @ jquery.min ...
<button onclick="querySessionId()">查詢session ID</button>
function querySessionId(){ var sessionId; $.ajax({ type:"post", url:"kuaibeiPro/querySessionId", async:true, dataType:"text", success:function(data){ console.dir("sessionId is :"+ data); return data; } }); return null; }
/** * 這個方法是為白騎士準備的,在前端代碼中嵌入的白騎士script代碼里要獲取實時的sessionid,為了確保實時,每次要 * 使用sessionid時都用ajax先獲取一下,然後再作為參數使用。 */ @RequestMapping(value = "/querySessionId", method = RequestMethod.POST) @ResponseBody String doQuerySessionId(HttpServletRequest request) throws Exception { String sessionId=request.getSession().getId(); System.out.println("======================== sessionId:"+sessionId); return sessionId; }
@ResponseBody一定一定要加啊!!!!!!
不加的話前臺報錯,後臺警告!!!!
前臺:
jquery.min.js:2 POST http://172.13.31.75:8080/kuaibeiPro/querySessionId 404 (Not Found)send @ jquery.min.js:2v.extend.ajax @ jquery.min.js:2querySessionId @ (index):74onclick @ VM1301:1n @ ionic.bundle.min.js:22t @ ionic.bundle.min.js:22l @ ionic.bundle.min.js:22
jquery.min.js:2 XHR finished loading: POST "http://172.13.31.75:8080/kuaibeiPro/querySessionId".
後臺:
[WARN] [2017-09-05 09:51:37.986] [org.springframework.web.servlet.PageNotFound.http-bio-8080-exec-6] # No mapping found for HTTP request with URI [/kuaibeiPro/404] in DispatcherServlet with name 'spring-web'