By default, where does Spring Boot expect views to be stored?

后端 未结 8 1974
盖世英雄少女心
盖世英雄少女心 2020-12-01 06:29

I\'m experimenting on re-writing my configuration-heavy, vanilla Spring MVC project using Spring Boot. I started a brand new Spring Boot project in IntelliJ using the Spring

相关标签:
8条回答
  • 2020-12-01 07:11

    According to answer given by @Jasbin karki I tried and found placing your html or jsp files in main->webapp->views folder(you should create the webapp & views folders) and adding the following lines in application.properties file does the task. Add the following in application.properties:

    spring.mvc.view.prefix=/views/
    
    spring.mvc.view.suffix=.html //or .jsp- if its a jsp file
    
    0 讨论(0)
  • 2020-12-01 07:21

    application.properties

    Remove:

    spring.mvc.view.prefix=/view/
    spring.mvc.view.suffix=.jsp
    

    Add:

    spring.thymeleaf.prefix= /WEB-INF/views/
    spring.thymeleaf.suffix= .html
    

    pom.xml

    Remove jasper dependency:

    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
        <scope>provided</scope>
    </dependency>
    

    Add thymeleaf dependency:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    

    Details: Using thymeleaf instead of jsp

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