thymeleaf和bootstrap及boot学习笔记1

最近想搞一实习相关设计,选了一下技术,js 我不会那就是排除前后端分离了,前后端不分离那就是我们的 jsp 和模板技术了啊

jsp想学但是好像目前市面上除了政府银行国企就没啥人用了 那以后学

先谈谈模板thymeleaf 和freemarker以及velocity;velocity据说更新慢,所以少有人用了,freemarker历史悠久但是比较难一点 所以选择Thymeleaf了啊 样式不会写 那只有用bootstrap了啊

模板用途就是显示页面数据,比如说我们页面静态化之类的

官网www.thymeleaf.org

<table>
  <thead>
    <tr>
      <th th:text="#{msgs.headers.name}">Name</th>
      <th th:text="#{msgs.headers.price}">Price</th>
    </tr>
  </thead>
  <tbody>
    <tr th:each="prod: ${allProducts}">
      <td th:text="${prod.name}">Oranges</td>
      <td th:text="${#numbers.formatDecimal(prod.price, 1, 2)}">0.99</td>
    </tr>
  </tbody>
</table>

整合boot和Thymeleaf+mybatis

1

然后等待下载配置yml

spring:
  # 模板引擎
  thymeleaf:
    mode: HTML
    encoding: utf-8
    # 禁用缓存
    cache: false
    prefix: classpath:/templates/
    suffix: .html
server:
  port: 8080

创建index

创建model层

package cn.xinyuan.demo.contoller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author xiaozheng
 * @description
 * @date 2023/2/23$
 */
@Controller
public class FirstIndex {
    @RequestMapping("first")
    public String first(Model modelAndView){
        modelAndView.addAttribute("name","boot和模板整合");
        return "index";
    }
}

最后启动


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>boot和模板整合</title>
</head>
<body>
    <input type="text"  value="boot和模板整合">
</body>
</html>

入门结束 boot 2.5.6版本 jdk+8

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值