@H_404_1@我有一个JSP页面检索数据,当单引号或双引号出现在文本中时,它们显示为此符号.
@H_404_1@JSP代码:
@H_404_1@
>’ – > ??
>“ – > ??
>” – > ??
>– – > ?? @H_404_1@我确信某些格式的其他字符会给我带来问题,但是,我只是替换了字符以进行临时修复,我目前正在测试下面的建议. @H_404_1@[解决方案代码] @H_404_1@这可能不是最好的方法,但它完成了工作.从数据库中检索数据后,下面的代码位于支持bean中. @H_404_1@
Meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
@H_404_1@示例:订单的描述应如下所示,
@H_404_1@“20 – 4”x 6“小部件”
@H_404_1@但我得到了这个,
@H_404_1@“20 – 4 x 6小部件”
@H_404_1@注意:我无法修改数据库.
@H_404_1@[编辑]
@H_404_1@我用commons-lang-2.4.jar来逃避角色,这些是给我带来麻烦的主要角色:
@H_404_1@>‘ – > ??>’ – > ??
>“ – > ??
>” – > ??
>– – > ?? @H_404_1@我确信某些格式的其他字符会给我带来问题,但是,我只是替换了字符以进行临时修复,我目前正在测试下面的建议. @H_404_1@[解决方案代码] @H_404_1@这可能不是最好的方法,但它完成了工作.从数据库中检索数据后,下面的代码位于支持bean中. @H_404_1@
description = StringEscapeUtils.escapeHtml(description);
description = description.replaceAll("‘",""");
description = description.replaceAll("’",""");
description = description.replaceAll("“",""");
description = description.replaceAll("”",""");
description = description.replaceAll("–","-");
description = StringEscapeUtils.unescapeHtml(description);
最佳答案