My Angular + Spring Application routing does not work when deployed on TomCat

后端 未结 1 795
刺人心
刺人心 2020-12-20 02:26

I am very much new to angular and spring. I might have made some silly mistakes. I have Angular + Spring app which displays login screen and after that it shows menu. This w

相关标签:
1条回答
  • 2020-12-20 02:37

    Try to add this in your Spring Boot code:

    @Bean
    public ErrorViewResolver customErrorViewResolver() {
        final ModelAndView redirectToIndexHtml = new ModelAndView("forward:/index.html", Collections.emptyMap(), HttpStatus.OK);
        return (request, status, model) -> status == HttpStatus.NOT_FOUND ? redirectToIndexHtml : null;
    }
    

    It works for me and even Angular routing is working. I found it here.

    0 讨论(0)
提交回复
热议问题