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

JavaBean的问题

热度:353   发布时间:2006-11-04 09:58:46.0
JavaBean的问题

JavaBean类UserBean.java

public class UserBean {
private String Name;
private String Num;

public UserBean() {

}
public void setUserName(String name){
Name=name;
}
public void setUserNum(String num){
Num=num;
}

public String getUserName() {
return Name;
}


public String getUserNum() {
return Num;

}
}
把编译好的JavaBean程序 放置在“web-inf/classes”目录中
<%@ page contentType="text/html; charset=GBK" language="java" import="java.sql.*" errorPage="" %>
<%
request.setCharacterEncoding("GBK");
%>
<html>
<head>
<title>javaBean的使用</title>
</head>

<body>
<jsp:useBean id="dada" scope="session" class="UserBean"/>
<jsp:setProperty name="dada" property="userName" param="name"/>
<jsp:setProperty name="dada" property="userNum" param="do"/>
<table width="40%" border="1">
<tr>
<td width="30%">
姓名:
</td>
<td width="70%">
<jsp:getProperty name="dada" property="UserName"/>
</td>
</tr>
<tr>
<td>
职业:
</td>
<td>
<jsp:getProperty name="dada" property="UserNum"/>
</td>
</tr>
</table>
</body>
</html>
打开时这个页面出现
HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

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

exception

org.apache.jasper.JasperException: /4-1.jsp(11,0) The value for the useBean class attribute UserBean is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:146)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1223)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1116)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Generator.generate(Generator.java:3270)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:189)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


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


--------------------------------------------------------------------------------

Apache Tomcat/5.5.9
这是怎么回事啊 ? 希望帮我解决一下 谢谢~

搜索更多相关主题的帖子: JavaBean  String  public  Num  UserBean  

----------------解决方案--------------------------------------------------------

怎么没人理我啊


----------------解决方案--------------------------------------------------------
The value for the useBean class attribute UserBean is invalid.
这个错误提示不是已经告诉你了吗
----------------解决方案--------------------------------------------------------
出现异常,The value for the useBean class attribute UserBean is invalid.

----------------解决方案--------------------------------------------------------

是不是class文件要放到包里才可以?


----------------解决方案--------------------------------------------------------
最好是用包来组织,这样便于管理,也便于使用
----------------解决方案--------------------------------------------------------
太容易出问题了,不太号判断.
----------------解决方案--------------------------------------------------------
  相关解决方案