Spring Boot JSP 404

后端 未结 14 1489
陌清茗
陌清茗 2020-11-28 07:17

I\'m trying to add a jsp page in my Spring Boot service. My problem is that every time I try to go to that page I have this:

Whitelabel Error Page

14条回答
  •  天涯浪人
    2020-11-28 07:29

    This is working solution for me about White label error page : Cannot find view page(jsp)

    At POM.xml, Make sure packaging is "war" and add tomcat/jasper dependencies

    war
    
                org.springframework.boot
                spring-boot-starter-tomcat
                provided
            
    
        
            org.apache.tomcat.embed
            tomcat-embed-jasper
            provided
        
    

    Add prefix/suffix at application.properties

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

    ** If you use Intellij, you must set Web Resource directories. At Project Structure (ctrl+alt+shift+ S) > Facets > Select Web(your application) > Add(+) Web Resource Directories ( mine is ......\src\main\webapp)

    ** If you have multiple modules(At intellij), Run> Edit configuration> Select springboot your application > Configuration tab> Working directory as $MODULE_WORKING_DIR$

提交回复
热议问题