jsp页面展示MySQL表数据时出现问题!

HTTP Status 500 - Unable to compile class for JSP:


type Exception report

message Unable to compile class for JSP:

description The server encountered an internal error that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 13 in the jsp file: /index.jsp
goodsVO cannot be resolved to a type
10:

商品展示
11:
12: <%
13: List lists = (List) request.getAttribute("lists");
14: %>
15:
16:

An error occurred at line: 13 in the jsp file: /index.jsp
goodsVO cannot be resolved to a type
10:

商品展示
11:
12: <%
13: List lists = (List) request.getAttribute("lists");
14: %>
15:
16:

Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:468)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

note The full stack trace of the root cause is available in the Apache Tomcat/7.0.35 logs.


Apache Tomcat/7.0.35

6个回答

我后台new的是ArrayList,需要改jsp里面的内容吗?

niaonao
niaonao 对啊,改为ArrayList lists = (ArrayList)request.getAttribute("lists");
大约 3 年之前 回复

你要看一下从后台传送来的数据类型是否是list类型;
你试一下用ArrayList定义。

这句话An error occurred at line: 13 in the jsp file: /index.jsp
goodsVO cannot be resolved to a type
不是说了类型不对吗?后台request.setAttribut() key-value中 value是否是list类型,你用arraylist试一下

是不是你jsp界面接收的类型和你在数据库中定义的类型不同?

List lists = (List) request.getAttribute("lists");

把具体类型加上

需要 把接受过来的list泛型 注意要引入 你所泛型的类到jsp中

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问