gpt4 book ai didi

java - GWT HTML 不显示换行符

转载 作者:行者123 更新时间:2023-12-01 11:59:23 24 4
gpt4 key购买 nike

我正在尝试显示带有换行符的 GWT UiField HTML 对象,但它似乎不起作用。

我接受一个字符串,使用 SimpleHtmlSanitizer 对其进行清理,然后换行符在 AlertWidget(一个 DialogBox)中显示为文本而不是 html。

@UiField
HTML description;

public AlertWidget(String htmlMessage) {
SafeHtml safeMessage = SimpleHtmlSanitizer.sanitizeHtml(htmlMessage);
setWidget(uiBinder.createAndBindUi(this));
this.description.setHTML(safeMessage);
}

在页面上,对话框的内容最终看起来与输入字符串完全相同:

The first error<br>the second error

我可以在我的 ide 中看到清理后的 SafeHtml 包含 safe 值:

The first error&lt;br&gt;the second error

最佳答案

查看 sanitizeHtml 的文档。顶部有一个支持的标签列表。不支持断线标记。

我会尝试一些其他机制来创建 SafeHTML:

关于java - GWT HTML 不显示换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28098191/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com