简体   繁体   English

Spring 引导:“404 jsp 页面未找到”在远程服务器中运行时

[英]Spring Boot: `404 jsp page not found` when runned in remote server

I have this simple project in Spring Boot.我在 Spring Boot 中有这个简单的项目。 You can see my directory (it is just a default directory)你可以看到我的目录(它只是一个默认目录)

I've added this extra dependency:我添加了这个额外的依赖项:

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

and this (to applicaiton.properties file):和这个(到applicaiton.properties文件):

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

Everything works fine when I run it with Intellij IDEA .当我使用Intellij IDEA运行它时,一切正常。 I can see the home.jsp page.我可以看到home.jsp页面。

在此处输入图像描述

But when I upload and run the jar file in remote server (I am using https://www.digitalocean.com ubuntu ) I get 404: not found error: But when I upload and run the jar file in remote server (I am using https://www.digitalocean.com ubuntu ) I get 404: not found error:

在此处输入图像描述

I suggest to do some checks:我建议做一些检查:

Check if:检查是否:

  1. Your application is deployed您的应用程序已部署
  2. WEB-INF folder is present WEB-INF 文件夹存在

In addition, if you are using tomcat and your application is not getting start, check if Application.class is extending SpringBootServeltInitializer.此外,如果您正在使用 tomcat 并且您的应用程序没有启动,请检查 Application.class 是否正在扩展 SpringBootServeltInitializer。

Remember that when you start application into Intellij, it starts with or without SpringBootServletInitializer but application need it in order to start in external Tomcat environment.请记住,当您将应用程序启动到 Intellij 时,它会在有或没有 SpringBootServletInitializer 的情况下启动,但应用程序需要它才能在外部 Tomcat 环境中启动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM