我将一个值作为请求属性传递给 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);
我必须将此文本作为请求参数发送到服务器。当我查看 Firebug 时,我看到一个错误。我正在尝试使用引发错误的 "value"= "${text}"
。我做错了什么?
SyntaxError: unterminated string literal
[Break On This Error]
{ "name": "description", "value": "
最佳答案
您应该使用 StringEscapeUtils.escapeJava
来处理没有任何 HTML 的字符串内容
StringEscapeUtils.escapeJava("Hello 1F World (Hello World) Hello World"));
关于java - 如何将带有空格和括号的文本传递给java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15795503/