添加依赖
<!--JSP依赖-->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
添加webapps目录并设置目录
设置工作目录,如果在IDEA中项目结构为聚合工程。那么在运行jsp是需要指定路径。如果项目结构为独立项目则不需要。
在 yml配置文件中配置视图解析器参数
在控制类中声明单元方法请求转发jsp资源
package com.msb.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* @Author: Ma HaiYang
* @Description: MircoMessage:Mark_7001
*/
@Controller
public class PageController {
@RequestMapping("/{uri}")
public String getPage(@PathVariable("uri") String uri){
return uri;
}
}