在JSP中,如何输出“". [英] In JSP, how to output "<br/>"

查看:192
本文介绍了在JSP中,如何输出“".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Struts2操作中有一个字符串var,如下所示:

I have a string var in my Struts2 action, like this:

String tmp = "<br/>";

我想通过JSP将其作为HTML标记打印到html页面,

I want to print it out to the html page as HTML tag by JSP, like this:

<s:property value="tmp"/>

但是,在html页面中,<>被翻译为我不想使用的&lt;&gt;.

But, in the html page, the < and > was translated to &lt; and &gt; which i don't want to.

那我应该怎么做?

推荐答案

<s:property>具有escape属性

<s:property> has an escape attribute which determines if the value is HTML-escaped. The default is true, so that's why your <br/> is being escaped.

因此您可以执行以下操作:

So you can do something like this:

<s:property value="tmp" escape="false"/>

这篇关于在JSP中,如何输出“".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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