关于此主题的问题很多,但我只在重新加载页面时遇到问题:reload a vuejs page (e.g. F5)
页面重新加载时,该URL被调出(但是vue页面):GET https://localhost:8444/company 404
我找到了这个示例,但对我不起作用(因为未调用此控制器):
// Forwards all routes to FrontEnd except: '/', '/index.html', '/api', '/api/**'
// Required because of 'mode: history' usage in frontend routing, see README for
// further details
@RequestMapping(value = "{_:^(?!index\\.html|api).*$}")
public String redirectApi() {
logger.info("URL entered directly into the Browser, so we need to redirect...");
return "forward:/";
}
它经过的最后一个类是此过滤器类:
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
try {
...
} catch (Exception e) {
....
}
filterChain.doFilter(request, response);
}
确保Conf:
protected void configure(HttpSecurity http) throws Exception {
http.cors().and().csrf().disable()
.exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
.authorizeRequests().antMatchers("/api").permitAll()
.antMatchers("/api/**").permitAll()
// .anyRequest().authenticated()
;
http.addFilterBefore(authenticationJwtTokenFilter(), UsernamePasswordAuthenticationFilter.class);
}
项目结构:structure
我是Springboot / VUE的新手,希望有人能帮助我