springboot项目,使用jsp作为前端页面。在application.yml配置了jsp所在位置
spring.mvc.view.prefix: /WEB-INF/jsp/
spring.mvc.view.suffix: .jsp
@Controller
@RequestMapping(value = "/user")
public class UserController {
@Autowired
UserService userService;
@RequestMapping(value = "/getAllUser")
public String getAllUser(){
//return userService.getAllUser();
return "index";
}
}
项目启动spring boot时报错,访问http://localhost:8080/user/getAllUser报错找不到页面
原因是:spring boot默认不使用jsp,需要在pom中引用jsp的编译程序:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
访问成功