LIULIANG

Attribute value is quoted with " which must be escaped when used within the value 问题解决

访问JSP时,报错:Attribute value is quoted with " which must be escaped when used within the value 。相信很多人都遇到过,以下结合本人查资料与亲自实践得到的结论。

有不对的地方还请指教。

 

1):错误常发生的位置 value="<%=""+request.getAttribute("name")%> 

2):错误产生的原因,是因为tomcat版本升级后(6.0以后),对双引号的处理机制引起的,如果出现双引号包含双引号的情况,就可能会出现这个错误。

3):解决办法有好多种,大多数网上的意见是改为value=<%=""+request.getAttribute("name")%>’  这样确实可以解决这个报错,可能无法完全解决问题,比如项目中有很多地方以前都用的是双引号,修改起来会非常麻烦,还容易出错。

         查看tomact文档有一段话这样描述的“If false the requirements for escaping quotes in JSP attributes will be relaxed so that an unescaped quote will not cause an error.

If not specified, the specification compliant default of true will be used.”    这个描述针对的是tomact的org.apache.jasper.compiler. Parser.STRICT_QUOTE_ESCAPING属性。

       如此一来,我们知道只要在tomcat启动时将这个属性设为false就可以解决这个问题。

       那么怎么将这个属性设置到tomcat的system属性中呢,有至少两个办法:

      一种是利用tomcat启动的执行脚本,在执行过程中调用setenv.sh,在其中设置环境变量,如:JAVA_OPTS=%JAVA_OPTS%: -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false

     另一种是找到conf/catalina.properties文件,在最后添加org.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false 即可。

 转自:http://blog.csdn.net/eagleking012/article/details/6666860

posted on 2012-08-15 08:41 BIG森林 阅读(326) 评论(0)  编辑 收藏 引用 所属分类: java web


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2012年8月>
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678

导航

统计

常用链接

留言簿(2)

随笔分类

随笔档案

搜索

最新评论

阅读排行榜

评论排行榜