Spring Boot JSP 404

后端 未结 14 1448
陌清茗
陌清茗 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:35

    We were adding Spring Boot to our system in order to run it as executable application without standalone tomcat and also faces the 404 status during JSP initialization.
    What should be done for fixing it:

    a) Add dependencies to your pom file (WARNING: tomcat-embed-jasper must have compile scope no provided):

    
     org.springframework.boot
         spring-boot-starter-parent
         2.3.3.RELEASE
         
     
     
       
         org.springframework.boot
         spring-boot-starter-web
       
       
         javax.servlet
         jstl
       
       
         org.apache.tomcat.embed
         tomcat-embed-jasper
       
     
    

    b) Add spring boot maven plugin for building your application:

    
        
          
            org.springframework.boot
            spring-boot-maven-plugin
          
        
    
    

    c) Check that you are using *.war file for your artifact, not jar (because of JSP support limitation):

    war
    

    e) Now you should be able to run your spring boot application using maven plugin or with command line - java -jar /you/path/application-name.war:

    f) But if you are using multi-module maven project and want to run spring boot application using IntelliJ Idea it is important to change "Working directory" -> $MODULE_DIR$:

提交回复
热议问题