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-Origin",
request.getHeader("Origin"));

 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: param.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 .

Technology
©2019-2020 Toolsou All rights reserved,
( Essence )2020 year 8 month 13 day C# Basic knowledge windform Realize two color sphere ( Essence 2020 year 6 month 2 Daily update ) TypeScript Function explanation TypeScript- Polymorphism common 5 species JAVA Runtime exception mysql Modify primary key 【Python- data fetch 】 read txt Each line of file generates a list of data ( Essence 2020 year 6 month 3 Daily update ) TypeScript Detailed explanation of Chinese interface element ui Drop down box search function python read , write in txt Text content mysql No backup recovery