您的位置:首页 > 运维架构 > Tomcat

tomcat升级报错

2015-08-03 16:38 741 查看
问题1 出现:

Attribute value request.getContextPath() + "/formula/taskRepetition.do" 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(最好是在${tomcat}/bin/catalina.sh中追加CATALINA_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

问题1 出现The JSP specification requires that an attribute name is preceded by whitespace是对应的jsp页面标签中没有加空格造成的eg:
<tr>
<td class="td_left">上传附件:</td>
<td class="td_right"><html:file name="contentForm" property="uploadFile"styleId="uploadFile" styleClass="td_form" /></td>
</tr>
styleId处

也可以在conf/catalina.properties文件,在最后添加
org.apache.jasper.compiler.Parser.STRICT_WHITESPACE=false
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: