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

网站如何做友情链接有道云笔记WordPress

网站如何做友情链接,有道云笔记WordPress,免费下载app软件安装,帝国cms制作网站地图Thymeleaf 支持 HTML 原型#xff0c;可以让前端工程师在浏览器中直接打开查看样式#xff0c;也可以让后端工程师结合真实数据查看显示效果 Thymeleaf 除了展示基本的 HTML #xff0c;进行页面渲染之外#xff0c;也可以作为一个 HTML 片段进行渲染#xff0c;例如我们在…Thymeleaf 支持 HTML 原型可以让前端工程师在浏览器中直接打开查看样式也可以让后端工程师结合真实数据查看显示效果 Thymeleaf 除了展示基本的 HTML 进行页面渲染之外也可以作为一个 HTML 片段进行渲染例如我们在做邮件发送时可以使用 Thymeleaf 作为邮件发送模板 SpringBoot 提供了 Thymeleaf 自动化配置解决方案: 这些默认的配置我们几乎不需要做任何更改就可以直接使用了。如果开发者有特殊需求则可以在 application.properties 中配置以 spring.thymeleaf 开头的属性即可 ①、配置类属性org.springframework.boot.autoconfigure.thymeleaf.ThymeleafProperties 首先通过 ConfigurationProperties 注解将 application.properties 前缀为 spring.thymeleaf 的配置和这个类中的属性绑定前三个 static 变量定义了默认的编码格式、视图解析器的前缀、后缀等从前三行配置中可以看出来Thymeleaf 模板的默认位置在 resources/templates 目录下默认的后缀是 html这些配置如果开发者不自己提供则使用 默认的如果自己提供则在 application.properties 中以 spring.thymeleaf 开始相关的配置 ConfigurationProperties(prefix spring.thymeleaf) public class ThymeleafProperties {private staticfinal Charset DEFAULT_ENCODING StandardCharsets.UTF_8;public staticfinal String DEFAULT_PREFIX classpath:/templates/;public staticfinal String DEFAULT_SUFFIX .html;private boolean checkTemplate true;private boolean checkTemplateLocation true;private String prefix DEFAULT_PREFIX;private String suffix DEFAULT_SUFFIX;private String mode HTML;private Charset encoding DEFAULT_ENCODING;private boolean cache true;//... }②、配置类org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration 首先导入 ThymeleafProperties然后 ConditionalOnClass 注解表示当当前系统中存在 TemplateMode 和 SpringTemplateEngine 类时当前的自动化配置类才会生效即只要项目中引入了 Thymeleaf 相关的依赖这个配置就会生效 Configuration EnableConfigurationProperties(ThymeleafProperties.class) ConditionalOnClass({ TemplateMode.class, SpringTemplateEngine.class }) AutoConfigureAfter({ WebMvcAutoConfiguration.class, WebFluxAutoConfiguration.class }) publicclass ThymeleafAutoConfiguration { }由于 Thymeleaf 模板后缀为 .html可以直接被浏览器打开 一、创建项目 创建完成后pom.xml 依赖如下 dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-thymeleaf/artifactId /dependency dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId /dependency二、创建Controller Controller public class IndexController{GetMapping(/index)public String index(Model model){ListUser users new ArrayList();for(int i 0; i 10; i){User u new User();u.setId((long) i);u.setName(javaboy: i);u.setAddress(深圳: i);users.add(u);}//在 IndexController 中返回逻辑视图名数据逻辑视图名为 indexmodel.addAttribute(users, users);return index;} }需要在 resources/templates 目录下提供一个名为 index.html 的 Thymeleaf 模板文件 !DOCTYPE html!--thymeleaf 名称空间-- html langen xmlns:thhttp://www.thymeleaf.org headmeta charsetUTF-8titleTitle/title /head body table border1trtd编号/tdtd用户名/tdtd地址/td/tr!--对model.addAttribute(users, users);进行遍历--tr th:eachuser : ${users}td th:text${user.id}/tdtd th:text${user.name}/tdtd th:text${user.address}/td/tr /table /body /html配置完成后就可以启动项目了访问 /index 接口就能看到集合中的数据了 三、Thymeleaf 支持在 js 中直接获取 Model 中的变量 Controller public class IndexController {GetMapping(/index)public String index(Model model) {model.addAttribute(username, 李四);returnindex;} }script th:inlinejavascriptvar username [[${username}]];console.log(username) /script四、手动渲染 一般在邮件发送时候有用例如我在 resources/templates 目录下新建一个邮件模板 !DOCTYPE html html langen xmlns:thhttp://www.thymeleaf.org headmeta charsetUTF-8titleTitle/title /head body phello 欢迎 span th:text${username}/span加入 XXX 集团您的入职信息如下/p table border1trtd职位/tdtd th:text${position}/td/trtrtd薪水/tdtd th:text${salary}/td/tr /table img srchttp://www.javaboy.org/images/sb/javaboy.jpg alt /body /html这一个 HTML 模板中有几个变量要将这个 HTML 模板渲染成一个 String 字符串再把这个字符串通过邮件发送出去 首先注入一个 TemplateEngine 对象这个对象就是在 Thymeleaf 的自动化配置类中配置的即当我们引入 Thymeleaf 的依赖之后这个实例就有了然后构造一个 Context 对象用来存放变量调用 process 方法进行渲染该方法的返回值就是渲染后的 HTML 字符串然后我们将这个字符串发送出去 Autowired TemplateEngine templateEngine;Test public void test1() throws MessagingException{Context context new Context();context.setVariable(username, javaboy);context.setVariable(position, Java工程师);context.setVariable(salary, 99999);String mail templateEngine.process(mail, context);//省略邮件发送 }
http://www.w-s-a.com/news/522333/

相关文章:

  • 贵阳企业网站建设制作赤峰浩诚网站建设公司
  • asp官方网站微信模板素材
  • wordpress 留言给站长发邮件做百度推广员赚钱吗
  • 北京建站公司做网站价格专门找人做软件的网站
  • 商务网站的特点ui软件界面设计
  • 广州个性化网站开发网站索引量是什么意思
  • 公司网站制作专业公司python做后台网站的多吗
  • 桂林建站平台哪家好给别人做网站怎么收取费用
  • python做网站显示表格用visual做的网站
  • 彩票网站建设需要什么聊城网站建设首选天成网络
  • 安徽建设工程网站wordpress标签云代码
  • 推荐佛山顺德网站建设手机网站建设域名空间
  • 电子商务网站建设策划书例子企业官网用什么cms系统
  • 网站栏目设计怎么写平面设计接单报价表
  • 做网站美工要学什么网站推广的方法包括
  • 哪个网站可以做笔译兼职wordpress加表单
  • 百度站内搜索 wordpress微餐饮建站费用
  • 用什么做网站的访问量统计制作手工作品
  • 微信公众号搭建网站河南卫生基层系统网站建设
  • steam账号注册网站重庆手机版建站系统哪家好
  • 中新生态城建设局门户网站wordpress云盘视频播放
  • 大型网站开发基本流程wordpress记录用户搜索
  • 云服务器安装win系统做网站wordpress边栏扩大尺寸
  • 网站开发面试自我介绍软件下载网站如何建设
  • 可以做翻译任务的网站陕西省建设厅八大员证
  • 昆明 网站推广重庆网页优化seo公司
  • 网站排名下降怎么上去设计一套app页面多少钱
  • 专门用来查找网址的网站查公司名字是否被注册
  • 自己创建网站教程河南省建设厅官方网站李学军
  • 一个网站需要多少容量怎样免费设计网站建设