我想把一个Hits类型的对象放入application,然后再转出来,不知道为什么不能用,代码如下:
Hits hits;
if (application.getAttribute("hits") == null)
{
hits = searcher.search(qq, sort);
application.setAttribute("hits", hits);
}
else
{
hits = application.getAttribute("hits");
} 出现错误:
exception org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 52 in the jsp file: /search2.jsp
Generated servlet error:
Type mismatch: cannot convert from Object to Hits
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)