jsp - JSP 页面中用字符替换的 HTML 字符实体

标签 jsp tomcat web-applications html-entities html-escape-characters

我在 Tomcat Webapp web.xml 文件中有以下 context-param 元素:

<context-param>
  <param-name>S_ALL_RIGHT_RESERVED</param-name>
  <param-value>Tous droits r&#233;serv&#233;s</param-value>
</context-param>

我在 JSP 中有以下代码:

<div>
  Without cout: ${initParam['S_ALL_RIGHT_RESERVED']}
  <br />
  With cout: <c:out value="${initParam['S_ALL_RIGHT_RESERVED']}"></c:out>
</div>

如果我查看页面的源代码,下面是我得到的:

<div>
  Without cout: Tous droits réservés
  <br />
  With cout: Tous droits réservés
</div>

我想得到的是:

<div>
  Without cout: Tous droits r&#233;serv&#233;s
  <br />
  With cout: Tous droits r&#233;serv&#233;s
</div>

你能告诉我哪里出了问题吗? 谢谢。

最佳答案

在你的 web.xml 中,试试这个:

<param-value><![CDATA[Tous droits r&#233;serv&#233;s]]></param-value>

关于jsp - JSP 页面中用字符替换的 HTML 字符实体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33398509/

相关文章:

java - 使用servlet和jsp注销后如何防止查看页面

java - 设计问题 - 在 Controller 或 View 中对数组进行排序?

java - 使用 java6 从 Tomcat6 调用 JAX-WS RI 2.2 服务

javascript - Firebase 身份验证有效但不断刷新页面

java - 从 HTML 调用本地 Java 库

升级到 Tomcat 7 后 JSP/JSF 文档无法正确呈现

java - 错误 : Unable to load configuration. - 操作,在 eclipse 上的 apache 上运行 Struts 2 时由 : Action class not found , 引起

spring - Spring Boot http2如何处理同时不支持http2的浏览器请求?

Eclipse 没有在多模块 Maven 项目中加载依赖模块

iphone - 检测非全屏 WebApp 的加载方式(主屏幕 v. Safari)