报错:Attribute value is quoted with " which must be escaped when used with in the value 。

访问JSP时,报错:Attribute value is quoted with " which must be escaped when used with in the value 。
1):错误常发生的位置 value="<%=""+request.getAttribute("name")%>"  
2):错误产生的原因,是因为tomcat版本升级后(6.0以后),对双引号的处理机制引起的,如果出现双引号包含双引号的情况,就可能会出现这个错误。

3):解决办法有好多种,大多数网上的意见是改为value=‘<%=""+request.getAttribute("name")%>‘如此一来,我们知道只要在tomcat启动时将这个属性设为false就可以解决这个问题。那么怎么将这个属性设置到tomcat的system属性中呢,有至少

两个办法:

方法 1:

是利用tomcat启动的执行脚本,在执行过程中调用setenv.sh,在其中设置环境变量,如:JAVA_OPTS=%JAVA_OPTS%: -

Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false

方法 2:

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

方法 3:使用转义字符("\")

例子

<jsp:include page="split_page.jsp">

<jsp:param name="jspUrl" value="<%=jspUrl%>" />

<jsp:param name="category" value="<%=equest.getParameter(\"category\")%>" />

<jsp:param name="searchFlag" value="T" />

</jsp:include>

猜你喜欢

转载自blog.csdn.net/Zx0307/article/details/77950077