【发布时间】:2021-01-07 14:28:17
【问题描述】:
我正在尝试构建一个 spring boot 应用程序,当我加载一个 jsp 页面时它显示 404 错误 我正在使用 jasper 加载 jsp 下面是我的代码 主文件
@SpringBootApplication
public class SpringAppApplication {
public static void main(String[] args) {
SpringApplication.run(SpringAppApplication.class, args);
}
}
控制器文件
@Controller
public class ApplicationController {
@RequestMapping("home")
public String home() {
return "index";
}
}
属性文件
server.port=8000
spring.mvc.view.suffix=.jsp
spring.mvc.view.prefix=/WEB-INF/pages/
依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-jasper -->
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jasper</artifactId>
<version>9.0.38</version>
</dependency>
</dependencies>
当我运行应用程序并访问 http://localhost:8000/home 时,我会得到一个 404
如何解决这个问题?
【问题讨论】:
标签: java spring spring-boot spring-mvc web