简介 目录 评价 推荐
  • 斌哥在此 2019-06-23
    <!DOCTYPE html>
    <html lang="en" xmlns:th="http://www.thymeleaf.org">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
        <a href="" th:href="@{https://www.jianshu.com/u/{id}(id=${id})}">激活帐号</a>
    </body>
    </html>

    测试

    @Autowired
    TemplateEngine templateEngine;
    
    Context context=new Context();
    context.setVariable("id","f192766abeab");
    String emailContent=templateEngine.process("emailTemplate",context);
    mailService.sendHtmlMail("邮箱","主题",emailContent);


    0赞 · 0采集
  • 不要问我有没有对象 2019-06-03

    语法HTML th:href:

    href地址:@{路径/{id}(id=${id})}

    截图
    0赞 · 0采集
  • 不要问我有没有对象 2019-06-03

    HTML邮件模板:

    支持包

        <dependency>

            <groupId>org.springframework.boot</groupId>

            <artifactId>spring-boot-starter-thymeleaf</artifactId>

    </dependency>

    创建HTML中:

    <html lang="en" xmlns:th="thymel官网路径(http://www.thymeleat.otg)">   :可以使用thymel,thymel是以th标签开头

    注:thymel有个特点,所以元素必须闭合,不然会报错


    java代码:

    TemplateEngine templateEngine:用于解析模板文件 

    Context context = new Context();

    context.setVariable('id','id值');    //设置id

    读取文本HTML:String eamilContext =templateEngine.process("模板名字(HTML名字)",context)



    截图
    0赞 · 0采集
  • 赵丽颖No_11207 2018-11-14

    thymeleaf的用法我学到了,之前用的都是参数形式,没想到还能用
    ·templateEngine.process("html名",传入参数)·

    截图
    1赞 · 0采集
数据加载中...
开始学习 免费