springboot-支持jsp

将Springboot工程打成war部署到web容器

1)pom文件中需要“一排二增”
A. 需要将tomcat从web组件中排除:


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

B. 新增对jsp和jstl支持的组件


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


	javax.servlet
	jstl

2)pom文件中将打包方式设置城war

war

3)在application.properties文件中增加jsp存放路径的配置

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

C. 添加一个ServletInitialinizer

public class ServletInitializer extends SpringBootServletInitializer {
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(JspApplication.class);
    }
}

你可能感兴趣的:(springboot)