惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Attack and Defense Labs
Attack and Defense Labs
T
Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
H
Hackread – Cybersecurity News, Data Breaches, AI and More
I
Intezer
C
Cyber Attacks, Cyber Crime and Cyber Security
The Register - Security
The Register - Security
量子位
Security Latest
Security Latest
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
C
CXSECURITY Database RSS Feed - CXSecurity.com
MyScale Blog
MyScale Blog
J
Java Code Geeks
Apple Machine Learning Research
Apple Machine Learning Research
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
Spread Privacy
Spread Privacy
Jina AI
Jina AI
博客园 - 【当耐特】
P
Palo Alto Networks Blog
Last Week in AI
Last Week in AI
SecWiki News
SecWiki News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
G
GRAHAM CLULEY
宝玉的分享
宝玉的分享
Hacker News - Newest:
Hacker News - Newest: "LLM"
T
The Blog of Author Tim Ferriss
V
Vulnerabilities – Threatpost
有赞技术团队
有赞技术团队
T
Tor Project blog
H
Hacker News: Front Page
A
Arctic Wolf
NISL@THU
NISL@THU
A
About on SuperTechFans
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
V
V2EX
N
News and Events Feed by Topic
Webroot Blog
Webroot Blog
Know Your Adversary
Know Your Adversary
P
Privacy International News Feed
I
InfoQ
D
Docker
L
LINUX DO - 最新话题
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
U
Unit 42

博客园 - Johnson_wang

对云服务器挂载cos桶 记录一次xxlJob升级版本导致的 xxl-job remoting error(Connection reset) 记一次NoClassDeffoundEror问题解决过程 nginx配置支持ws,并解决跨域 关于消费端接入dubbo,连接失败问题 RedisTemplate关于key出现前缀\xac\xed\x00\x05t\x00\x0f - Johnson_wang - 博客园 ES 单索引大表拆分 关于ES索引被聚合查询导致filedata堵塞 (pressure too high, (smooth) bulk request circuit break) elasticsearch报错FORBIDDEN/12/index read-only / allow delete spring Boot 相关问题以及修复(后续待补充) mybatis数据加解密处理方案 队列缓存区-db写入 synchronized的实现原理 Scheduler踩坑记录 关于RedisTemplate的map存储踩坑记录 关于HashMap的加载因子相关理解 Mybatis 分页插件PageHelper 遇坑 Linux 下 Mysql忘记密码重置 Eclipse MAT和jvisualvm分析内存溢出
发送HTML格式邮件
Johnson_wang · 2022-09-15 · via 博客园 - Johnson_wang

主要在于构建HTML模板,新建类似模板:

<table border='0' th:each='data:${datas}' cellspacing='1' cellpadding='0'
       style='background:#DCDFE6; line-height: 30px;width: 900px;  left:auto;'>
    <tr style="color: #000000;text-align: left;font-weight: bold;">
        <td colspan='4'>任务名称:<span th:text='${data.taskName}'/></td>
    </tr>
    <tr style="text-align: left;">
        <th style='background:#FFF;width: 80px; '>ID</th>
        <th style='background:#FFF;'>名称</th>
        <th style='background:#FFF;width: 60px;'>时间</th>
        <th style='background:#FFF;width: 60px;'>数量</th>
    </tr>
    <tr th:each='item:${data.list}' style="text-align: left;">
        <td style="background: #FFF;width: 80px;" th:text='${item.id}'></td>
        <td style="background: #FFF;" th:text='${item.name}'></td>
        <td style="background: #FFF;width: 60px;" th:text='${item.time}'></td>
        <td style="background: #FFF;width: 60px;" th:text='${item.count}'></td>
    </tr>
    <br />
</table>

使用 thymeleaf 加载HTML,并赋值构造完整HTML页面。

引入插件:

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

构建HTML

SpringTemplateEngine templateEngine = new SpringTemplateEngine();
            Context context1 = new Context();
            context1.setVariable("datas",list);
            String content = templateEngine.process(mailInfo.getMailContent(),context1);

然后发送邮件