我正在尝试将换行标记
插入一些文本并将其显示在网页上。< 和 > 符号被翻译成<
and>
并且标签在网页上显示为文本。
当我从数据库中选择它时,文本看起来像这样(我已将其输出到 SYSOUT):
version 12.4
service timestamps debug datetime
service timestamps log datetime
service password-encryption
然后我通过这个小过滤器运行它:
public DevConfigs getDevConfig() {
String config = devConfig.getConfig();
Pattern pattern = Pattern.compile(".$", Pattern.MULTILINE | Pattern.DOTALL);
Matcher matcher = pattern.matcher(config);
String newConfig = matcher.replaceAll("<br />");
devConfig.setConfig(newConfig);
return this.devConfig;
}
这是网页(它是一个使用 facelets 的 Seam 应用程序):
<rich:tab label="Config">
hello<br />
there<br />
#{devConfig.config}
</rich:tab>
页面源如下所示:
hello<br />
there<br />
<br />
<br />
version 12.<br />
service timestamps debug datetim<br />
service timestamps log datetim<br />
service password-encryptio<br />
<br />
如您所见,我的标签以 HTML 字符而不是标签的形式出现。我需要做什么才能在每行文本的末尾插入换行符?
TDR