将保存的HTML打印到jsp不断损坏

时间:2014-08-21 21:29:26

标签: java javascript html jsp

我有一个JAVA对象,我保存一个HTML字符串值,我称之为消息。保存的数据如下所示,

You have received a new <a href='' onclick='return popupRentalView('5282053859835904');'>Rental Request 5282053859835904</a>.  Please view your open orders.

但是当打印到JSP文件并在运行时使用

显示时
<%=pm.getMessage()%>

<%out.print(pm.getMessage());%>

实际的html代码全部搞砸了,

You have received a new <a 5282053859835904');'="" onclick="return popupRentalView(" href="">Rental Request 5282053859835904</a>

。请查看您的未结订单。

有关显示的字符串与保存的字符串不匹配的任何想法?

用于保存的JAVA代码是

note.setMessage("You have received a new <a href=\"\" onclick='return popupRentalView('"
            + requestId
            + "');'> Rental Request "
            + requestId
            + "</a>.  Please view your open orders.");

1 个答案:

答案 0 :(得分:0)

@Musa谢谢你我发现你所指的是什么,修复是

保存的JAVA代码

note.setMessage("You have received a new <a href=\"\" onclick=\"return popupRentalView('" + requestId + "');\"> Rental Request " + requestId + "</a>. Please view your open orders.");

然后显示它我可以使用,

<%=pm.getMessage()%> or <c:out value="${showMessage.message}" escapeXml="false" />