当前位置: 代码迷 >> Java Web开发 >> JSTL和JavaBean的有关问题
  详细解决方案

JSTL和JavaBean的有关问题

热度:57   发布时间:2016-04-17 14:23:26.0
JSTL和JavaBean的问题
request.setAttribute( "userInfo ",   uib);
/*dd*/   System.out.println(uib);
RequestDispatcher   rd=request.getRequestDispatcher( "profile.jsp ");
rd.forward(request,   response);
我在已使用以上的代码把一个包含用户信息的bean设置到request中,该怎么在forward到的profile.jsp页中读取啊?
我在profile.jsp中加了以下代码:
<jsp:directive.page   import= "com.data.UserInfoBean "/>
<%@   taglib   uri= "http://java.sun.com/jstl/core_rt "     prefix= "c "   %>
<jsp:useBean   id= "userInfo "   class= "UserInfoBean "   scope= "request ">
<jsp:setProperty   name= "userInfo "   property= "* "   />    
</jsp:useBean>
调用时用的:
<c:out   value= "${param.userInfo.userName} "     />
但是老是提示出错:
org.apache.jasper.JasperException:   /admin/profile.jsp(5,0)   The   value   for   the   useBean   class   attribute   UserInfoBean   is   invalid.(jsp:useBean那一行)
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1175)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1117)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2164)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2214)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2220)
org.apache.jasper.compiler.Node$Root.accept(Node.java:457)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2164)
org.apache.jasper.compiler.Generator.generate(Generator.java:3322)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:199)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:296)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:299)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.qxauc.ViewUserDo.doPost(ViewUserDo.java:82)
com.qxauc.ViewUserDo.doGet(ViewUserDo.java:22)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.authenticate.AdminAccessFilter.doFilter(AdminAccessFilter.java:55)
com.uitl.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:27)
----------------------------------------------------
或者报错:
org.apache.jasper.JasperException:   Unable   to   load   class   for   JSP
org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:599)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:141)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.qxauc.ViewUserDo.doPost(ViewUserDo.java:82)
com.qxauc.ViewUserDo.doGet(ViewUserDo.java:22)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)