escapeXml和escapeHtml有什么区别?(What is the difference between escapeXml and escapeHtml?)
I would like to escape characters in JSP pages. Which is more suitable, escapeXml or escapeHtml?
解决方案
They're designed for different purposes, HTML has lots of entities that XML doesn't. XML only has 5 escapes:
< represents "<" > represents ">" & represents "&" ' represents ' " represents "
While HTML has loads - think of © etc. These HTML codes aren't valid in XML unless you include a definition in the header. The numeric codes (like © for the copyright symbol) are valid in both.
我想在JSP页面中转义字符。哪个更合适, escapeXml 或 escapeHtml ?
解决方案
它们是为了不同的目的而设计的,HTML有很多XML不支持的实体。 XML只有5个转义:
& lt; lt表示< & gt表示> & amp; amp代表& &代表' &代表
虽然HTML有加载 - 想想& nbsp; code> & copy; 等这些HTML代码在XML中无效,除非在标题中包含定义,数字代码(如&#169; 的版权符号)都有效。