Spring Boot非常适合Web应用程序开发。使用spring-boot-starter-web模块快速启动和运行。 其中使用嵌入式Tomcat,Jetty或Undertow轻松创建自包含的HTTP服务器
Spring Boot支持多种方式来创建一个项目:
- 使用curl命令 Using curl
- 使用Spring Boot CLI 命令行工具 Using CLI
- https://spring.io/ 在线生成项目
- 使用Spring的集成开发工具
创建Spring Boot项目:
这里简单在线生成一个项目; 直接访问https://start.spring.io/,填写Group和Artifact,添加Web和 Freemarker两个依赖项。 
 
Spring Boot 支持的可以替换JSP的,view engine包括: Thymeleaf, Groovy Markup Templates, Freemarker, Velocity. (As of Spring Framework 4.3, Velocity support has been deprecated due to six years without active maintenance of the Apache Velocity project. ) 除了Velocity 以外,其他根据个人爱好自助选择。
添加HomeController
@Controller
public class HomePageController {
    @RequestMapping("/")
    public String home(){
        return "index";
    }
}添加前端页面的模板
采用开源bootstrap的H5 模板:awesome template 
 默认页面文件需要添加至/src/main/resources/templates 下面;静态资源文件的位置在/src/main/resources/static (或者/src/main/resources/public)下面。 
 目录结构如下: 
 
运行SpringBootApplication主程序;访问http://localhost:8080验证。 截止目前,没有任何定制的情况下,我们可以看到Awesome 的模板页面。
github repo
spring-boot-trail-static-content tags/ootb
 
                   
                   
                   
                   
                             本文介绍如何使用SpringBoot快速创建Web应用,包括在线生成项目、添加依赖、配置控制器及前端模板等内容。支持多种视图引擎如Thymeleaf、Groovy等。
本文介绍如何使用SpringBoot快速创建Web应用,包括在线生成项目、添加依赖、配置控制器及前端模板等内容。支持多种视图引擎如Thymeleaf、Groovy等。
           
       
           
                 
                 
                 
                 
                 
                
               
                 
                 
                 
                 
                
               
                 
                 扫一扫
扫一扫
                     
              
             
                  
 被折叠的  条评论
		 为什么被折叠?
被折叠的  条评论
		 为什么被折叠?
		 
		  到【灌水乐园】发言
到【灌水乐园】发言                                
		 
		 
    
   
    
   
             
            


 
            