---java code----
package sunxin.org.ch09.beans;
import java.io.Serializable;
public class UserBean implements Serializable {
private String name;
private int sex;
private String email;
private String education;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getSex() {
return sex;
}
public void setSex(int sex) {
this.sex = sex;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getEducation() {
return education;
}
public void setEducation(String education) {
this.education = education;
}
}
---java code----
---html code----
用户信息填写
用户名: | |
性别: | 男 女 |
学历: | ....高中大学硕士博士 |
Email: | |
---html code---
---jsp code---
<%@ page contentType="text/html; charset=gbk" %>
<%
request.setCharacterEncoding("gbk");
%>
<jsp:setProperty name="user" property="*" />
<jsp:setProperty name="user" property="email" param="mail" />
注册成功!
---jsp code----
[color=red][size=medium]
访问reg.html,提交后报错:[/size][/color]
org.apache.jasper.JasperException: /WebContent/reg.jsp(5,1) The value for the useBean class attribute sunxin.org.ch09.beans.UserBean is invalid.
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:1203)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1160)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2393)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2399)
org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Generator.generate(Generator.java:3365)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:199)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:315)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
[size=medium]查了网上的帖子,通常的错误如下:
1. 在编译 JSP 时(不是运行时),指定的 Bean 类没找到
2. Bean 虽然找到了,但是它不是 public 的,或者找到的 class 文件是 interface 或抽象类
3. Bean 类中没有 public 的默认构建函数
这我这几个问题都没有的啊。 那么究竟是错在哪了呢?
[/size]
[b]问题补充:[/b]
加了没用呀。还是报那个错误.
import就是用来简写包名的,我jsp里用的是全名。
[b]问题补充:[/b]
我的类也位于了正确的地方啊
.../ch09/WEB-INF/classes/sunxin/org/ch09/beans/UserBean.class