在Spring MVC中通过JSTL显示html [英] display html via JSTL in Spring MVC

查看:120
本文介绍了在Spring MVC中通过JSTL显示html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有类似的东西

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

在我的控制器中。

在我的查看页面我写道

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

但输出为& lt; b> akhil& lt; / b> ,而不是< b> akhil< / b>。为什么会这样,应该怎么做才能获得< b> akhil< / b>

But the output is &lt;b>akhil&lt;/b> as against <b>akhil</b>. Why is it so and what should be done to get <b>akhil</b>.

推荐答案

这是因为< c:out> 对字符'<'>

设置选项 escapeXml = false c:out 以粗体字母输出文字:

Set the option escapeXml=false of c:out to output your text in bold letters:

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

这篇关于在Spring MVC中通过JSTL显示html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆