javax.servlet.ServletException: [Ljava.lang.Object; 红太狼 2021-08-11 06:32 216阅读 0赞 # HTTP Status 500 - # -------------------- **type** Exception report **message** **description** The server encountered an internal error () that prevented it from fulfilling this request. **exception** javax.servlet.ServletException: [Ljava.lang.Object; org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523) org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194) org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) javax.servlet.http.HttpServlet.service(HttpServlet.java:709) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) com.zq.utils.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:24) **root cause** java.lang.ClassCastException: [Ljava.lang.Object; com.zq.struts.user.action.UserAction.userLogin(UserAction.java:403) com.zq.struts.user.action.UserAction.doExecute(UserAction.java:118) com.zq.struts.action.BaseAction.execute(BaseAction.java:98) org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:106) org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194) org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) javax.servlet.http.HttpServlet.service(HttpServlet.java:709) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) com.zq.utils.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:24) **note** The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs. -------------------- 一下内容摘自互联网(转) String sql = "select \{P.\*\} from Personreg P where P.name = :name and P.password = :password"; 以上Query的list()方法返回的集合中存放的是对象数组的元素,这个对象数组中才是存放了Personreg对象。 应该if (iterator.hasNext())\{ Object\[\] row = (Object\[\])iterator.next(); Personreg personreg = (Personreg)row\[0\]; System.out.println(personreg.getId()); \} 另外String hql = "from Personreg P where P.name = :name and P.password = :password",这里,因为你语句中用了别名.属性名,所以前面一定要指定别名,否则语法错误; 或者不指定别名的前况下直接指定属性名就好,可以用String hql = "from Personreg where name = :name and password = :password"。
还没有评论,来说两句吧...