当我在Elastic Beanstalk上部署Spring Boot应用程序时,它找不到.jsp文件
我有一个简单的SpringBootWeb应用程序,它应该在本地运行。然而,当我将它部署在elastic beanstalk上时,我得到了404错误,该错误表示/WEB-INF/jsp/index.jsp未找到 以下是我的pom.xml:当我在Elastic Beanstalk上部署Spring Boot应用程序时,它找不到.jsp文件,spring,amazon-web-services,jsp,spring-boot,amazon-elastic-beanstalk,Spring,Amazon Web Services,Jsp,Spring Boot,Amazon Elastic Beanstalk,我有一个简单的SpringBootWeb应用程序,它应该在本地运行。然而,当我将它部署在elastic beanstalk上时,我得到了404错误,该错误表示/WEB-INF/jsp/index.jsp未找到 以下是我的pom.xml: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/200
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>arge</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>arge</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>javax.servlet.jsp.jstl-api</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
这是我的控制器类:
package com.example.arge.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class HelloController {
@GetMapping("/")
public String index() {
return "index";
}
}
jsp文件位于src/main/webapp/WEB-INF/jsp/index.jsp下。
一切似乎都正常,我无法找出问题出在哪里您想要访问的url是什么样子的?我只是尝试访问根/url,并在问题中添加了控制器类。请检查此答案:这些答案不起作用。。
package com.example.arge.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class HelloController {
@GetMapping("/")
public String index() {
return "index";
}
}