在 Java 中显示 HTML 时出现问题的标签
我的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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.