Spring Boot, Java Config - No mapping found for HTTP request with URI [/…] in DispatcherServlet with name 'dispatcherServlet'

前端 未结 3 411
春和景丽
春和景丽 2020-12-17 18:50

This has been a quite common problem here in stackOverflow, but none of the topics of the same problem solves mine.

We have a template configuration that uses xml co

相关标签:
3条回答
  • 2020-12-17 18:59

    The tips here helped me when I got stuck with a similar problem. I fixed it after adding this fragment on my configuration

    @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }
    
    0 讨论(0)
  • 2020-12-17 19:01

    OK! Found the problem.

    This link helped me: https://samerabdelkafi.wordpress.com/2014/08/03/spring-mvc-full-java-based-config/

    More specifically this configuration:

    @Override
        public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
            configurer.enable();
        }
    

    By setting a default handler, I would no longer get a white page but instead the JSP code as html, which clearly tells me that the JSP was being found but not rendered.

    So the answer was on this page: JSP file not rendering in Spring Boot web application

    I was missing the tomcat-embed-jasper artifact.

    0 讨论(0)
  • 2020-12-17 19:04

    Add below dependency to your pom.xml

        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>provided</scope>
        </dependency>
    
    0 讨论(0)
提交回复
热议问题