如何将带有空格和括号的文本传递给java

时间:2013-04-03 18:46:46

标签: java javascript jsp jstl apache-stringutils

我将一个值作为请求属性传递给jsp页面。

request.setAttribute("description", StringEscapeUtils.escapeHtml("Hello 1F World (Hello World) Hello World"));

在jsp页面中,我在pageContext中设置

String text = (String) (String) request.getAttribute("description");
pageContext.setAttribute("description", text);

我必须将此文本作为请求参数发送到服务器。当我看着萤火虫时,我发现了一个错误。我试图使用"value" = "${text}"抛出错误。我做错了什么?

SyntaxError: unterminated string literal
[Break On This Error]   

{ "name": "description", "value": "

1 个答案:

答案 0 :(得分:2)

您应该使用StringEscapeUtils.escapeJava字符串中没有任何HTML的内容

StringEscapeUtils.escapeJava("Hello 1F World (Hello World) Hello World"));