Spring Boot JSP not found

泄露秘密 提交于 2021-01-27 10:43:40

问题


in my Spring Boot app I switched from Thymeleaf to JSP and it is working normally on my local computer, but when I upload it to Heroku server I get
There was an unexpected error (type=Not Found, status=404). /WEB-INF/jsp/home.jsp

its jar packaged, what does it mean if its working locally but not on Heroku server?

edit, project structure


回答1:


Try adding this to pom.xml:

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

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

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
    </dependency>

and adding this to application.properties:

spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp

and moving JSPs to src/main/webapp/WEB-INF/jsp.



来源:https://stackoverflow.com/questions/45684146/spring-boot-jsp-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!