弹簧引导+ Mybatis + Spring MVC环境配置(五):模板模板使用

  

     

     <李>   

     

  李   <李>   

     

  李   <李>   

     

  

     

  李      

     

  

     

  

     

  

     

  

     

  

     

  

     

  <前>   #,Check  that 从而template  exists  before  rendering 它。   spring.thymeleaf.check-template=true   #,Check  that 从而templates 位置存在。   spring.thymeleaf.check-template-location=true   #,Content-Type  value  written 用HTTP 反应。   spring.thymeleaf.content-type=text/html   #,Enable  Thymeleaf  view  resolution  for  Web 框架。   spring.thymeleaf.enable=true   #,Template  files 编码。   spring.thymeleaf.encoding=utf - 8   #,Comma-separated  list  of  view  names  that  should  be  excluded 得到解决。   spring.thymeleaf.exclude-view-names=指数   #,Prefix  that  gets  prepended 用view  names  when  building  a  URL。   spring.thymeleaf.prefix=类路径://模板   spring.thymeleaf.suffix=. html   #,Template  mode 用be  applied 用模板只阅读also  StandardTemplateModeHandlers。   HTML5 spring.thymeleaf.mode=#,Disable  template 缓存。   spring.thymeleaf.cache=false   之前   

  
  

  

  二,在pom.xml添加依赖   

  <前>   & lt; dependency>   & lt; groupId> org.springframework.boot   & lt; artifactId> spring-boot-starter-thymeleaf   & lt;/dependency>   之前   

  
  

  

  三、在资源目录下创建模板文件夹,并添加模板html   
  

  

  弹簧引导+ Mybatis + Spring MVC环境配置(五):模板模板使用“>
  </p>
  <p>
  test.html
  <br/>
  </p>
  <前>
  & lt; ! DOCTYPE  html>
  & lt; html>
  & lt; head>
  & lt; meta  charset=癠TF-8"祝辞
  & lt; title> Insert  title  here</title>
  & lt;/head>
  & lt; body>
  姓名:& lt; span  th:文本=? {user.username}“祝辞& lt;/span> & lt;/br>
  邮箱:& lt; span  th:文本=? {user.email}“祝辞& lt;/span> & lt;/br>
  昵称:& lt; span  th:文本=? {user.nickname}“祝辞& lt;/span>
  & lt;/body>
  & lt;/html>
  </>之前
  <p>
  <br/>
  </p>
  <p>
  四,增加控制器
  </p>
  <前>
  @ controller
  public  class  TemplatesController  {
  
  @ autowired
  private  UserService  userService;
  @RequestMapping (“/index")
  String 测试(ModelMap 地图),{
  map.addAttribute (“key之前   

  
  

  

  五、运行结果   

  

  弹簧引导+ Mybatis + Spring MVC环境配置(五):模板模板使用“>
  </p>
  <p>
  到这里,春天引导+ Mybatis + Spring MVC环境就搭建完成了
  </p>
  <p>
  <br/>
  </p>
  <p>
  完整环境下载地址:
  
  https://github.com/CatherineHu/Spring-Boot-Mybatis-MVC
  
  ,
  </p><h2 class=弹簧引导+ Mybatis + Spring MVC环境配置(五):模板模板使用