springboot整合jsp模板

在使用springboot框架里使用jsp的时候,页面模板使用jsp在pom.xnl中需要引入相关的依赖,否则在controller中无法返回到指定页面

〇、搭建springboot框架

一、添加jsp相关的依赖如下:



javax.servlet
javax.servlet-api
provided



javax.servlet
jstl



org.springframework.boot
spring-boot-starter-tomcat
provided



org.apache.tomcat.embed
tomcat-embed-jasper
provided

二、配置文件

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

三、controller

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import com.xujie.service.CountService;

@Controller
public class CountController {

@Autowired
private CountService countService;

//跳转页面
@GetMapping("/index")
public String goIndex() {
return "index";
}
}

四、在/WEB-INF/jsp下编写index.jsp页面

 posted on 2018-02-23 15:54  徐杰  阅读(260)  评论(0)    收藏  举报