Jena 和 jsp 类型不匹配
朋友们。嗯,这是一个很长的问题,但根据杰克的说法,让我们分部分来看。 在这个片段中 ++++++++++
<%
List<`enter code here`String> sugestao = request.getAttribute("sugestao");
Iterator it = sugestao.iterator();
while(it.hasNext()) {
out.print("<br> conceito:"+ it.next());
}
%>
我收到一条错误消息,指出存在类型不匹配,因此无法将对象转换为列表。 “sugestao”来自一个servlet。 {...}
List<String> sugestao = listaConceitos.getListaConceitos(caminho);
request.setAttribute("sugestao", sugestao);
RequestDispatcher view = request
.getRequestDispatcher("SequenciaDosConceitos.jsp");
// passa para frente.
view.forward(request, response);}}
顺便说一句:caminho 是一个 RDF 路径。 我需要一些帮助来解决这个麻烦。我尝试了类型转换,但没有成功...我需要一些提示吗?我在爪哇海里迷路了!
friends. Well it is a long question, but according Jack, let's go by parts.
In this snippet
++++++++++
<%
List<`enter code here`String> sugestao = request.getAttribute("sugestao");
Iterator it = sugestao.iterator();
while(it.hasNext()) {
out.print("<br> conceito:"+ it.next());
}
%>
I got an error message saying that there is a type mismatch, so that it is not possible to convert an object to a List. "sugestao" came from a servlet.
{...}
List<String> sugestao = listaConceitos.getListaConceitos(caminho);
request.setAttribute("sugestao", sugestao);
RequestDispatcher view = request
.getRequestDispatcher("SequenciaDosConceitos.jsp");
// passa para frente.
view.forward(request, response);}}
BTW: caminho is a RDF path.
I need some help to solve this trouble. I tryied a type cast, but didn't work... I need some hint? I got lost in the sea of Java!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ServletRequest.getAttribute()
方法不支持泛型。将该行更改为
“显然,只有当
sugestao
” 的类型为List
时,这才有效。所以在你的代码中的某个地方你应该有这样的东西:The
ServletRequest.getAttribute()
method does not support generics. Change the lineto
Obviously, this will only work if
sugestao
is of typeList<String>
. So somewhere in your code you should have something like this: