Attribute value request.getParameter("name") is quoted with " which must be escaped when used
来源:互联网 发布:软考程序员 编辑:程序博客网 时间:2024/06/06 03:01
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文档有一段话这样描述的“Iffalsethe 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 oftruewill 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 即可。
方法 3:使用转义字符("\")
1<jsp:include page="split_page.jsp">
2 <jsp:param name="jspUrl" value="<%=jspUrl%>" />
3 <jsp:param name="category" value="<%=equest.getParameter(\"category\")%>" />
4 <jsp:param name="searchFlag" value="T" />
5</jsp:include>
- Attribute value request.getParameter("name") is quoted with " which must be escaped when used
- Attribute value request.getParameter("itemID") is quoted with " which must be escaped when used with
- 问题解决: Attribute value request.getParameter("id") is quoted with " which must be escaped when used wi
- 问题解决: Attribute value request.getParameter("id") is quoted with " which must be escaped when used wi
- Attribute value request.getParameter("digyso") is quoted with " which must be escaped when used within the value
- 问题解决: Attribute value request.getParameter("id") is quoted with " which must be escaped when used within the value
- Attribute value request.getAttribute("keyWord") is quoted with " which must be escaped when used wi
- Attribute value request.getAttribute("keyWord") is quoted with " which must be escaped when used wit
- Attribute value is quoted with " which must be escaped when used within the value 问题解决
- Attribute value is quoted with " which must be escaped when used within the value 问题解决
- Attribute value is quoted with " which must be escaped when used within the value 问题解决
- Attribute value is quoted with " which must be escaped when used within the value 问题解决
- Attribute value "xx" is quoted with " which must be escaped when used within the
- Attribute value ("XXX") is quoted with " which must be escaped when used within the value 异常的修正
- Attribute value ("XXX") is quoted with " which must be escaped when used within the value 异常的修正
- Attribute value ("XXX") is quoted with " which must be escaped when used within the value 异常的修正1
- Attribute value ("XXX") is quoted with " which must be escaped when used within the value 异常的修正2
- Attribute value ("XXX") is quoted with " which must be escaped when used within the value 异常的修正1
- mongo aggregate聚合查询
- Ubuntu下hadoop集群安装
- 【小竹韶IT】第一回 免费电话之争
- Outlook2010 VBA添加联系人
- Startup and Shutdown
- Attribute value request.getParameter("name") is quoted with " which must be escaped when used
- 第十四周项目二 带姓名的成绩单(数据由score.txt提供)
- Skyline查询实验数据点的生成
- 编译qt2.2的问题
- 【微信公众平台应用开发实践】API详解--基础接口
- 第14周项目3-(1)(2)
- Max Points on a Line
- 第14周 项目2-带姓名的成绩单(1)
- [windows phone开发]锁屏背景