记一次springboot 配置JSP

记一次springboot 配置JSP

结构
记一次springboot 配置JSP_第1张图片
pom.xml

   <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
        </dependency>
        <!--用于编译jsp-->
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>provided</scope>
        </dependency>

application.properties

spring.mvc.view.prefix=/WEB-INF/
spring.mvc.view.suffix=.jsp
#静态文件访问配置
spring.mvc.static-path-pattern=/static/**
spring.resources.static-locations=classpath:/static/,classpath:/resources/


启动类

@SpringBootApplication
public class TravleApplication extends SpringBootServletInitializer {
    //在servlet3.0之后,支持注解配置,所以spring对其进行了封装,我们不用配置web.xml,继承此类,并将相应的bean穿进去,会自动扫描,
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(TravleApplication.class);
    }
    public static void main(String[] args) {
        SpringApplication.run(TravleApplication.class, args);
    }

}

controller

@Controller
public class IndexController {
    @GetMapping("/")
    public String ToIndex(){
        return "index";
    }
}

选择项目F4进入modules设置jsp数据源
记一次springboot 配置JSP_第2张图片

你可能感兴趣的:(java)