在 Java 中显示 HTML 时出现问题的标签

发布于 2024-09-27 10:25:42 字数 571 浏览 1 评论 0原文

我的 HTML 中包含以下标记,这会导致 JEditorPane 不显示 HTML 输出。

<META http-equiv="Content-Type" content="text/html; charset=UTF-8">

没什么大不了的,但有人知道为什么会发生这种情况吗?

找不到太多关于此的文档 - 我想到的最好的办法是几年前有人尝试过 逆转录病毒站点

目前我正在对字符串进行简单的查找替换,这不好 - 有没有更好的方法?我看到很多人说 RegEx 不好。

我使用的代码是

this._html = this._html.replace( "<META http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", "");

Andez

I have the following tag included in my HTML which causes the JEditorPane not to show the HTML output.

<META http-equiv="Content-Type" content="text/html; charset=UTF-8">

Not so much a big deal but anyone know why this would happen?

Cannot find too much documentation on this - best I came up with was someone having a go a few years ago to see what was supported on retro virus site.

At the minute I'm doing a simple find replace on the string which is not good - are there any better ways? I've seen a lot of people saying that RegEx is no good.

The code I have used is

this._html = this._html.replace( "<META http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", "");

Andez

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怪我太投入 2024-10-04 10:25:42

RegEx 不适合解析完整的 HTML 文档。但在这种情况下,我认为这样做没有任何问题。

对于你刚才的问题,我实在是不知道。

RegEx is not good for parsing the full HTML document. But in this case, I don't find any problem going with that.

Regarding your former question, I really don't have no idea.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文