2 回答
TA贡献1848条经验 获得超6个赞
在你的 pom.xml 中删除
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>javax.servlet.jsp.jstl-api</artifactId>
<version>1.2.1</version>
</dependency>
并添加这些依赖项
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
据我所知,tomcat-embed-jasper需要在启动时呈现jsp页面。
TA贡献1777条经验 获得超3个赞
1.viewResolver.setPrefix("/WEB-INF/views/"); 视图->视图
2.spring可以实现ErrorController
@Controller
public class ViewController implements ErrorController {
@GetMapping("/home")
public String home(Model model) {
System.out.println("___________home()___________________");
return "home";
}
@GetMapping("/error")
public String error(Model model) {
System.out.println("___________ERROR-<<error___________________");
return "home";
}
@Override
public String getErrorPath() {
return "/error";
}
}
添加回答
举报