GWT HTML 不显示换行符
GWT HTML not showing line breaks
我正在尝试显示带有换行符的 GWT UiField HTML 对象,但它似乎不起作用。
我接受一个字符串,使用 SimpleHtmlSanitizer
对其进行清理,然后换行符显示为文本而不是 AlertWidget 中的 html,这是一个 DialogBox
。
@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<br>the second error
查看 sanitizeHtml 的文档。在顶部有一个支持的标签列表。不支持断线标记。
我会尝试一些其他机制来创建 SafeHTML:
我正在尝试显示带有换行符的 GWT UiField HTML 对象,但它似乎不起作用。
我接受一个字符串,使用 SimpleHtmlSanitizer
对其进行清理,然后换行符显示为文本而不是 AlertWidget 中的 html,这是一个 DialogBox
。
@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<br>the second error
查看 sanitizeHtml 的文档。在顶部有一个支持的标签列表。不支持断线标记。
我会尝试一些其他机制来创建 SafeHTML: