动态HTML在Thymeleaf中

huangapple go评论66阅读模式
英文:

Dynamic HTML in Thymeleaf

问题

我正在创建一个 Spring MVC + Thymeleaf 项目。我希望用户能够控制页面的某些部分,也就是用户可以使用 HTML 标签更改文本,并进行格式化,比如更改颜色、字体大小等。然而,我尚未找到将动态 HTML 插入到 Thymeleaf HTML 模板中的方法。有没有办法可以实现这样的操作?

编辑:我真的必须使用 JavaScript 来实现吗?Thymeleaf 真的没有任何将动态生成的 HTML 插入静态 HTML 模板的方式吗?

谢谢。

英文:

I am creating a Spring MVC + Thymeleaf project. I would like the user to have control over some parts of the page, meaning that user could change text and format is as well with colors, font sizes, etc., using HTML tags. However, I have not found any way how to insert dynamic HTML into thymleaf HTML template. Is there any way how to do it ?

EDIT: Do I really have to use JS in order to be able to achieve that ? Thymeleaf really does not have any way of inserting dynamically generated HTML inside static HTML th template ?

Thanks.

答案1

得分: 1

由于Thymeleaf不限制您使用任何喜欢的前端库,您可以随意使用任何现有的所需所见即所得编辑器。其中之一是TinyMCE。另一个优秀的编辑器是Summernote。这里有一个教程详细描述了如何在Spring和Thymeleaf中使用它:https://frontbackend.com/thymeleaf/spring-boot-bootstrap-thymeleaf-rich-text-editor

但同样地:Thymeleaf并没有特别之处。您可以使用任何您喜欢的HTML/JavaScript所需所见即所得编辑器。

英文:

As Thymeleaf doesn't limit you in using any frontend libraries you like, you can just use any existing WYSIWYG editor you like. TinyMCE is one of them. Another great editor is Summernote. Here's a Tutorial describing in detail how to use it with Spring and Thymeleaf: https://frontbackend.com/thymeleaf/spring-boot-bootstrap-thymeleaf-rich-text-editor

But again: there's nothing special about Thymeleaf. You can use any HTML/JavaScript WYSIWYG editor you like.

huangapple
  • 本文由 发表于 2020年8月28日 03:49:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/63623238.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定