zoukankan      html  css  js  c++  java
  • thymeleaf初步使用

    thymeleaf模板引擎初步使用

    #thymelea模板配置
    spring.thymeleaf.prefix=classpath:/templates/
    spring.thymeleaf.suffix=.html
    spring.thymeleaf.mode=HTML5
    spring.thymeleaf.encoding=UTF-8
    spring.thymeleaf.servlet.content-type=text/html
    spring.thymeleaf.cache=false
    spring.resources.chain.strategy.content.enabled=true
    spring.resources.chain.strategy.content.paths=/**
    
    @RequestMapping("/user")
    @Controller
    public class IndexController {
        @RequestMapping("index")
        public ModelAndView index(ModelAndView modelAndView){
            modelAndView.setViewName("index");
            modelAndView.addObject("name","XXX");
            return modelAndView;
        }
    
        @RequestMapping("home")
        public String home(){
            return "home";
        }
    
        @RequestMapping("/map")
        public String map(Map<String,String> map){
            map.put("map","map");
            return "map";
        }
    }
    
    <!DOCTYPE html>
    <html lang="en"  xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
        <h1 th:text="${name}"></h1>
    </body>
    </html>
    

  • 相关阅读:
    jquery 实现 返回顶部
    js 10秒倒计时 功能
    2019.6.10 工作日志
    2019.4.25 工作日志
    2019.4.22 工作日志
    2019.4.13 工作日志
    2019.3.12 工作日志
    2019.1.22 工作日志
    2019.1.18 工作日志
    2019.1.14 工作日志
  • 原文地址:https://www.cnblogs.com/yanfei1819/p/9856402.html
Copyright © 2011-2022 走看看