日期:2014-05-17  浏览次数:20833 次

关于javaBean调试无错,浏览器访问出错的问题
我在Eclipse Java EE IDE中调试没问题,但当我用浏览器访问是运行到引入的javabean时出错,请问一下是什么原因,使用tomcat6.0代码如下:
index.jsp

<%@ page language="java" contentType="text/html; charset=GBK"
  pageEncoding="GBK"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>Insert title here</title>
</head>
<body>
<form action="reg.jsp" method="post">
<table align="center" width="400" height="200" border="1">
<tr>
<td align="center" colspan="2" height="40">
<b>添加用户信息</b>
</td>
</tr>
<tr>
<td>姓 名:</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td>性 别:</td>
<td><input type="text" name="sex"></td>
</tr>
<tr>
<td>年 龄:</td>
<td><input type="text" name="age"></td>
</tr>
<tr>
<td>地 址:</td>
<td><input type="text" name="add"></td>
</tr>
<tr>
<td align="center" colspan="2"><input type="submit" value="添加"> <input type="reset" value="重置"></td>
</tr>
</table>
</form>
</body>
</html>


reg.jsp文件


<%@ page language="java" contentType="text/html; charset=GBK"
  pageEncoding="GBK"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>Insert title here</title>
</head>
<body>
<%request.setCharacterEncoding("GBK"); %>
<jsp:useBean id="person" class="person.Person" scope="page">
<jsp:setProperty name="person" property="*"/>
</jsp:useBean>
<table align="center" width="400" border="1">
<tr>
<td colspan="2">用户信息</td>
</tr>
<tr>
<td>姓 名:</td>
<td><jsp:getProperty property="name" name="person"/></td>
</tr>
<tr>
<td>性 别:</td>
<td><jsp:getProperty property="sex" name="person"/></td>
</tr>
<tr>
<td>年 龄:</td>
<td><jsp:getProperty property="age" name="person"/></td>
</tr>
<tr>
<td>地 址:</td>
<td><jsp:getProperty property="add" name="person"/></td>
</tr>
<tr>
<td align="center" colspan="2"><a href="index.jsp">返回</a></td>
</tr>
</table>

</body>
</html>


person类


package person;

public class Person {
private String name;
private String sex;
private String age;
private Str