ajax請求的時候解決跨域問題,不用spring的responsBody

response.addHeader("pragma", "no-cache"); html

response.addHeader("cache-control", "no-cache,must-revalidate"); 跨域

response.addHeader("expires", "0"); spa

//解決跨域問題htm

response.setHeader("Access-Control-Allow-Origin", "*"); //這句代碼解決跨域問題。get

response.setContentType("text/html;charset=UTF-8"); it

response.setCharacterEncoding("UTF-8"); date

response.setDateHeader("Expires", 0L); coding

response.getWriter().write(JSONObject.toJSONString(ms)); cache-control

response.getWriter().flush();di

相關文章
相關標籤/搜索