zoukankan      html  css  js  c++  java
  • Spring Boot thymeleaf模版支持,css,js等静态文件添加

    Thymeleaf引入

    Thymeleaf是一个Java模板引擎开发库,可以处理和生成HTML、XML、JavaScript、CSS和文本,在Web和非Web环境下都可以正常工作。

    1.添加依赖包

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>

    2.添加配置项目

    # 模板配置
    # 这个开发配置为false,避免改了模板还要重启服务器
    spring.thymeleaf.cache=false
    # 这个是配置模板路径的,默认就是templates,可不用配置
    spring.thymeleaf.prefix=classpath:/templates/
    # 这个可以不配置,检查模板位置
    spring.thymeleaf.check-template-location=true
    # 下面3个不做解释了,可以不配置
    spring.thymeleaf.suffix=.html
    spring.thymeleaf.encoding=UTF-8
    spring.thymeleaf.content-type=text/html
    
    # 模板的模式
    spring.thymeleaf.mode=HTML5

    3.添加

     @RequestMapping("/list")
        public String  listUser(Model model) {
            List<User> userList = new ArrayList<User>();
            for (int i = 0; i <10; i++) {
                userList.add(new User(i,"张三"+i,20+i,"中国广州"));
            }
            
            model.addAttribute("users", userList);
            return "/user/list";
        }
  • 相关阅读:
    bootstrap常用快捷查找
    jquery
    javascript
    移动端心得总结
    css。过渡动画
    css。。段落样式
    css。元素样式、边框样式
    css3
    css
    Hbuilder 的快捷方式
  • 原文地址:https://www.cnblogs.com/Guroer/p/10162891.html
Copyright © 2011-2022 走看看