Debugging a project with front and back separated , The information has been saved to session Yes , Again from session Unable to get the current user information ,debug find sessionId It has changed , I checked a lot of information on the Internet , Not accurate ,

Share your solutions :

Back end interceptor :

// Interceptor adds cross domain support ( If it is web.xml Configuring Interceptors , Please send @component delete ) //@Component public class
CORSFilterimplements Filter { @Override public void init(FilterConfig
filterConfig)throws ServletException { } @Override public void doFilter
(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain
filterChain)throws IOException, ServletException { HttpServletRequest request =
(HttpServletRequest) servletRequest; HttpServletResponse response =
(HttpServletResponse) servletResponse; response.setHeader(
"Access-Control-Allow-Origin", request.getHeader("Origin")); response.setHeader(
"Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
response.setHeader("Access-Control-Max-Age", "3600"); response.setHeader(
"Access-Control-Allow-Headers", "x-requested-with"); response.setHeader(
"Access-Control-Allow-Credentials","true"); // Yes no cookie Cross domain
filterChain.doFilter(servletRequest, servletResponse); } @Override public void
destroy() { } }

Key points :


 response.setHeader("Access-Control-Allow-Credentials","true"); // Yes no cookie Cross domain

Preceding code :

request: function(param) { var _this = this; $.ajax({ xhrFields: {
withCredentials: true }, type: param.method || 'get', url: param.url || '',
dataType: param.type || 'json', data: || '', success: function(res) {
console.log(" Network request results :"+res.toString()); // Request succeeded }, error: function(err) { typeof
param.error ==='function' && param.error(err.statusText); } }); }, Key points :

    stay ajax Add in request

      xhrFields: {
           withCredentials: true

Through the above configuration , Solved my problem perfectly ! If you have any questions, please leave me a message .

©2019-2020 Toolsou All rights reserved,
java Four functional interfaces ( a key , simple ) It's unexpected Python Cherry tree (turtle The gorgeous style of Library ) Browser kernel ( understand )HashMap Explain in detail Some East 14 Pay change 16 salary , Sincerity or routine ?html Writing about cherry trees , Writing about cherry trees