当前位置: 代码迷 >> Web前端 >> Attribute value request.getAttribute("XXX") is quoted with " 有关问题
  详细解决方案

Attribute value request.getAttribute("XXX") is quoted with " 有关问题

热度:935   发布时间:2012-11-23 22:54:33.0
Attribute value request.getAttribute("XXX") is quoted with " 问题
在进行MVC+DAO实现分页的时候碰到了这个异常:
严重: Servlet.service() for servlet PersonServlet threw exception
org.apache.jasper.JasperException: /person10.jsp(35,41) Attribute value request.getAttribute("lineSize")  is quoted with " which must be escaped when used within the value
	at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
	at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
	at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:198)
	at org.apache.jasper.compiler.Parser.parseQuoted(Parser.java:302)
	at org.apache.jasper.compiler.Parser.parseAttributeValue(Parser.java:249)
	at org.apache.jasper.compiler.Parser.parseAttribute(Parser.java:210)
	at org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:148)
	at org.apache.jasper.compiler.Parser.parseParam(Parser.java:870)
	at org.apache.jasper.compiler.Parser.parseBody(Parser.java:1819)
	at org.apache.jasper.compiler.Parser.parseOptionalBody(Parser.java:1076)
	at org.apache.jasper.compiler.Parser.parseInclude(Parser.java:904)
	at org.apache.jasper.compiler.Parser.parseStandardAction(Parser.java:1227)
	at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1578)
	at org.apache.jasper.compiler.Parser.parse(Parser.java:130)
	at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:245)
	at org.apache.jasper.compiler.ParserController.parse(ParserController.java:101)
	at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:176)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
	at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:679)
	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:461)
	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:399)
	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
	at com.tangjian.servlet.PersonServlet.doGet(PersonServlet.java:91)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:873)
	at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
	at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
	at java.lang.Thread.run(Thread.java:595)


出现错误部分代码是
<jsp:include page="person_com.jsp">
				<jsp:param name="jspUrl" value="<%=jspUrl %>"/>
				<jsp:param name="lineSize" value="<%=request.getAttribute("lineSize") %>"/>
				<jsp:param name="currentPage" value="<%=request.getAttribute("currentPage") %>"/>
				<jsp:param name="allRecoders" value="<%=request.getAttribute("allRecoders") %>"/>
				<jsp:param name="keyWord" value="<%=request.getAttribute("keyWord") %>"/>
				<jsp:param name="searchFlag" value="T"/>
			</jsp:include>


搜索了下,在csdn中的
http://blog.csdn.net/qzj5851/archive/2009/08/12/4437493.aspx
中发现了相同的问题。按照他的解决方法修改如下:
<jsp:include page="person_com.jsp">
				<jsp:param name="jspUrl" value="<%=jspUrl %>"/>
				<jsp:param name="lineSize" value='<%=request.getAttribute("lineSize") %>'/>
				<jsp:param name="currentPage" value='<%=request.getAttribute("currentPage") %>'/>
				<jsp:param name="allRecoders" value='<%=request.getAttribute("allRecoders") %>'/>
				<jsp:param name="keyWord" value='<%=request.getAttribute("keyWord") %>'/>
				<jsp:param name="searchFlag" value="T"/>
			</jsp:include>

就是把value=""改成value=''

问题是解决了,但是看他里面说是tomcat6.0版本的问题,可是我使用的是tomcat5.5的版本也出现这个问题。
我这个项目是使用到了servlet的,我还有一个是使用JSP+DAO实现分页的项目。在那个项目里面同样的代码就没有出现过这个问题。
自己现在猜测是tomcat解析servlet时候出现的一个问题。留待有时间的时候再来解决。
  相关解决方案