gpt4 book ai didi

java - 在 Spring MVC 中通过 JSTL 显示 html

转载 作者:搜寻专家 更新时间:2023-10-30 20:59:47 25 4
gpt4 key购买 nike

我有类似的东西

model.addAttribute("msg", "<b>akhil</b>");
return "index";

在我的 Controller 中。

在我的 View 页面中我写了

<body>
<h2>Hello World!</h2>
<c:out value="${msg}" />
</body>

但输出是&lt;b>akhil&lt;/b><b>akhil</b>. 相比为什么会这样,应该怎么做才能得到<b>akhil</b> .

最佳答案

这是因为<c:out>使用 XML 转义字符 '<'> .

设置选项escapeXml=falsec:out以粗体字输出文本:

<c:out value="${msg}" escapeXml="false"/>

关于java - 在 Spring MVC 中通过 JSTL 显示 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9002988/

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