大体步骤:
(1)创建Maven web project;
(2)在pom.xml文件添加依赖;
(3)配置application.properties支持jsp
(4)编写测试Controller
(5)编写JSP页面
(6)编写启动类Application.Java
1,FreeMarker
2,Groovy
3,Thymeleaf (spring 官网使用这个)
4,Velocity
5,JSP (貌似Spring Boot官方不推荐,STS创建的项目会在src/main/resources 下有个templates 目录,这里就是让我们放模版文件的,然后并没有生成诸如 SpringMVC 中的webapp目录)
不过本文还是选择大家都熟悉的JSP来举例,因为使用JSP与默认支持的模版需要特殊处理,所以拿来举例更好。
(1)创建Maven web project
使用Eclipse新建一个Maven Web Project ,项目取名为:
spring-boot-jsp
(2)在pom.xml文件添加依赖
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://.example; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.support.SpringBootServletInitializer; //import org.springframework.boot.context.web.SpringBootServletInitializer; @SpringBootApplication public class Application extends SpringBootServletInitializer { public static void main(String[] args){ SpringApplication.run(Application.class, args); } }右键Run As Java Application访问:http://127.0.0.1:8080/helloJsp 可以访问到:
helloJsp
Hello Angel From application
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。