当前位置: 首页 > news >正文

松原市网站建设_网站建设公司_改版升级_seo优化

乐山乐人网站建设公司,网站两个域名,wordpress仿fe素材,营销网站开发渠道有哪些springboot发送邮件,内容使用thymeleaf模板引擎排版 1、导入jar包2、yml设置3、收件人以及收件信息设置4、发邮件service5、模版页面6、controller 1、导入jar包 !--发送邮件--dependencygroupIdorg.springframework.boot/groupIdartifac… springboot发送邮件,内容使用thymeleaf模板引擎排版 1、导入jar包2、yml设置3、收件人以及收件信息设置4、发邮件service5、模版页面6、controller 1、导入jar包 !--发送邮件--dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-mail/artifactId/dependency !--使用thymeleaf 形式--dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-thymeleaf/artifactId/dependency2、yml设置 发件邮箱信息设置 spring:mail:host: smtp.xx.cnport: 465username: 你的邮箱password: 你的密码 # default-encoding: UTF-8protocol: smtpproperties: # 配置以SSL的方式发送, 这个需要使用这种方式并且端口是465mail:smtp:auth: truessl:enable: truesocketFactory:class: com.sun.mail.util.MailSSLSocketFactoryfallback: falsedebug: true 3、收件人以及收件信息设置 Getter Setter public class AcceptMailParam {//标题private String title;//接收人邮件地址private String receiveEmail[];//抄送人邮件地址private String chaoSongPersonEmail[];//附件value 文件的绝对地址/动态模板数据private MapString, Object attachment;//thymeleaf模版引擎页面对象数据邮件排版内存ListOperateDataResultInfoView pageViewList; }页面对象数据展示 Setter Getter public class OperateDataResultInfoView {private Long id;/*** 存储当前年月,eg:202301*/private Integer curMonth;/*** 库名*/private String dbName;/*** 表名*/private String tableName;/*** 计划生成数据量*/private Long planGenDataCnt;/*** 实际生成数据量*/private Long actualGenDataCnt;/*** 备注*/private String remark;private String gmtCreate;private String gmtModified;/* ** 剩余待生成数据量*/private Long remainToGenCnt;/* ** 生成数据成功率(实际生成数量/计划生成数量),单位%*/private BigDecimal genDataSuccessRate;/**模拟生成数据*/public OperateDataResultInfoView() {this.id ThreadLocalRandom.current().nextLong(100L, 999L);this.curMonth DateUtil.getPreMonth();String[] dbAndTableName (dbName id .tableName id).split(\\.);this.dbName dbAndTableName[0];this.tableName dbAndTableName[1];this.planGenDataCnt id ThreadLocalRandom.current().nextLong(10L, 99L);this.actualGenDataCnt id;this.remark null;this.gmtCreate DateUtil.getNowStr();this.gmtModified DateUtil.getNowStr();this.remainToGenCnt (planGenDataCnt - actualGenDataCnt) 0 ? (planGenDataCnt - actualGenDataCnt) : 0;BigDecimal rate new BigDecimal(actualGenDataCnt).divide(new BigDecimal(planGenDataCnt), 4, BigDecimal.ROUND_HALF_UP);this.genDataSuccessRate rate.compareTo(new BigDecimal(1)) 0 ? new BigDecimal(100) : rate.multiply(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP);} }4、发邮件service public interface SendMailService {/*** 邮件内容排版调试*/AcceptMailParam getMailContentAndSendMail(Integer curMonth); }/*** 获取指定月份的邮件【邮件内容生成数据的结果集 信息】* 次月1日8点 发送*/Overridepublic AcceptMailParam getMailContentAndSendMail(Integer curMonth) {AcceptMailParam acceptMailParam new AcceptMailParam();ListOperateDataResultInfoView pageViewList new ArrayList();for (int i 0; i 10; i) {pageViewList.add(new OperateDataResultInfoView());}Collections.sort(pageViewList, Comparator.comparing(OperateDataResultInfoView::getId).reversed());acceptMailParam.setPageViewList(pageViewList);String[] emails {xxx1qq.com};String[] chaoSongPerson {xx2qq.com};//收件人支持多人acceptMailParam.setReceiveEmail(emails);//抄送人支持多人acceptMailParam.setChaoSongPersonEmail(chaoSongPerson);acceptMailParam.setTitle(统计业务表生成数据结果);//添加附件MapString, Object map new HashMap();//key为邮件附件文件名称路径改为你的服务器路径即可可添加不同类型文件map.put(1-test1.zip, /Users/gina/xx/data/test2.zip);map.put(2-test2.xlsx, /Users/gina/xx/data/test1.xlsx);acceptMailParam.setAttachment(map);//调试邮件内容排版时此处可注释掉。//this.sendTemplateMail(acceptMailParam,/mail/list);return acceptMailParam;}5、模版页面 在resources下在路径templates/mail/下添加文件list.html !DOCTYPE htmlhtml xmlns:thhttp://www.thymeleaf.orgstyletr.odd td {background-color: #f0faaa;}td.number {text-align: right;}table {width: 100%;border: 1px solid #000;border-collapse: collapse;}table tbody tr td, table thead tr th {padding: 2px 10px;border-left: 1px dotted #000000;vertical-align: top;line-height: 20px;}table tbody tr, table thead tr {border-bottom: 1px solid #000000;}table th {background-color: #99cc33;}table tbody tr td a, table tbody tr td a:hover {text-decoration: none;font-weight: bold;background-color: #352726;padding: 2px 10px;color: #f0faaa;margin-left: 10px;text-transform: uppercase;border: 0px;}/styleheadtitle统计业务表生成数据结果/titlemeta http-equivContent-Type contenttext/html; charsetUTF-8 //headbodyh1统计业务表生成数据结果/h1tabletrth生成月份/thth库名/thth表名/thth计划生成(条)/thth实际生成(条)/thth成功率%/thth未生成(条)/thth创建时间/thth更新时间/thth备注/th/trtr th:eacho : ${pageViewList} th:class${o.id % 2 0}? odd td th:text${o.curMonth} /tdtd th:text${o.dbName} /tdtd th:text${o.tableName} /tdtd th:text${o.planGenDataCnt} /tdtd th:text${o.actualGenDataCnt}/tdtd th:text${o.genDataSuccessRate}/tdtd th:text${o.remainToGenCnt}/tdtd th:text${o.gmtCreate}/tdtd th:text${o.gmtModified}/tdtd th:text${o.remark}/td/tr/table/body /html6、controller Controller Slf4j public class SendMailController {/*** 调试生成的页面样式不发邮件* 数据处理结果集view*/Resourceprivate SendMailService sendMailService;/** 点此可直接访问* http://localhost:8081/sendMail?curMonth202311*/RequestMapping(sendMail)public String sendMail(Model model, RequestParam(name curMonth) Integer curMonth) {try {AcceptMailParam acceptMailParam sendMailService.getMailContentAndSendMail(curMonth);model.addAttribute(title, acceptMailParam.getTitle());model.addAttribute(pageViewList, acceptMailParam.getPageViewList());} catch (Exception e) {log.error(sendMail fail ,msg{}, e.getMessage());}return mail/list;} }7、启动服务后访问页面展示 邮箱内容样式为 有对thymeleaf感兴趣的同学可通过中文官网去了解thymeleaf中文官网
http://www.ihoyoo.com/news/109558.html

相关文章:

  • 网站安全证书现在电商做的设计用的什么网站
  • 建立企业网站公司网络系统管理大赛样题
  • 织梦网站关闭手机版discuz网站搬家教程
  • 现在清算组备案在哪个网站做杭州网站建设
  • 深圳住建厅官方网站重庆企业服务建站网站开发
  • 第一次做网站时是怎样的心情长沙seo 优化选智投未来no1
  • 游学旅行网站建设策划书网站建设中的板块名称
  • 关于网站建设与维护的心得体会嘉兴网站建设模板网站
  • 车辆优化管理专业网站wordpress整合uc
  • 长春网站设计长春网络推广云梦网如何做网站
  • 成都网站建设潮州公司的网 网站打不开
  • 惠州微网站建设视频直播网站app开发
  • 广州网站制作设计公司南宁学网站建设
  • 网站建设加推广北京清控人居建设集团网站
  • 如何提高网站访问量wordpress集成微博登陆
  • 山东网站建设排行榜线上课程制作
  • 高端的培训行业网站开发深圳宝安建设工程交易中心
  • 做网站能不能赚钱wordpress修改侧边栏
  • 网站的开发包括什么东西wordpress默认摘要
  • 网站开发树形图济南seo优化
  • 出售源码的网站wordpress 插件 升级
  • 免费app下载网站seo培训班
  • 安徽网站开发培训价格哪些网站是单页面
  • 海南做网站找谁本地网站搭建如何访问网页
  • 公司网站开发部署网站建设服务商的网站建设流程
  • 盐山县做网站价格济南网站建设推广服务
  • 机电网站模板企业建设项目备案办法
  • 网站做百度推广去掉自动升级wordpress失败提示
  • 企业建设网站公司简介网站怎么做登录
  • 营销型网站5要素app购物商城