gpt4 book ai didi

html - 在Grails测试报告的系统输出中打印html标签

转载 作者:行者123 更新时间:2023-12-02 15:34:25 26 4
gpt4 key购买 nike

我正在尝试在 grails 测试报告中打印我的Spock规范的步骤说明。

我正在使用print/println在报告中提供此信息。

问题是我想将一些数据打印为HTML表,但是当我打印一些html标签(即<table>)时,<>(小于且大于符号)被打印为&lt&gt

有没有一种方法可以打印标签而不转换标签?

最佳答案

这里有一个答案:Java: How to unescape HTML character entities in Java?,建议使用org.apache.commons.lang.StringEscapeUtils.unescapeHtml(String str)

unescapeHtml

public static String unescapeHtml(String str)

Unescapes a string containing entity escapes to a string containing the actual 

Unicode characters corresponding to the escapes. Supports HTML 4.0 entities.

For example, the string "&lt;Fran&ccedil;ais&gt;" will become "<Français>"

If an entity is unrecognized, it is left alone, and inserted verbatim into

the result string. e.g. ">&zzzz;x" will become ">&zzzz;x".

关于html - 在Grails测试报告的系统输出中打印html标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14112644/

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