springboot集成jsp的Demo实现

1.创建一个maven web项目

2.添加springboot和jsp相关依赖


	org.springframework.boot
	spring-boot-starter-parent
	2.0.3.RELEASE


	
		junit
		junit
		3.8.1
		test
	
	
		org.springframework.boot
		spring-boot-starter-web
	
		
	
	
		org.springframework.boot
		spring-boot-starter-tomcat
	
	
		org.apache.tomcat.embed
		tomcat-embed-jasper
	
		

3.在application.properties配置文件中添加配置

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

4.创建一个controller

@EnableAutoConfiguration
@ComponentScan(basePackages="com.vhukze.controller")
@RestController
public class JspDemoController {

	@RequestMapping("/toJsp")
	public ModelAndView toJsp() {
		return new ModelAndView("index");
	}
	
	public static void main(String[] args) {
		SpringApplication.run(JspDemoController.class, args);
	}
}

5.在src/main下新建webapp目录,在webapp下面创建配置的路径

springboot集成jsp的Demo实现_第1张图片

 



Hello World!

6.启动项目访问controller映射路径

你可能感兴趣的:(springboot,java)