springboot整合jsp模板
在使用springboot框架里使用jsp的时候,页面模板使用jsp在pom.xnl中需要引入相关的依赖,否则在controller中无法返回到指定页面
〇、搭建springboot框架
一、添加jsp相关的依赖如下:
二、配置文件
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
浙公网安备 33010602011771号