救急呀——————救急呀——JAVABEAN调用问题

tomwen 2004-11-02 07:33:43
http://luoye1979414.vicp.net:8080/jsp-examples/tomwen/index.jsp
点击“注册”
然后输入注册信息在点击确定,然后出错!急急急急急急急急急急急急急急急急急
register.jsp代码如下
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ include file="include.inc"%>
<%@ include file="trans.jsp"%>

<%@ page contentType="text/html; charset=gb2312" language="java" errorPage="error.jsp" %>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><LINK
href="hellking.css" type=text/css rel=stylesheet>

<body>
<table width=88% border="1" height="100%" cellpadding="0" cellspacing="0" align="left" bordercolor="#000080" class=tablebody2>
<tr>
<td>

<script language="javascript">
<!-- Begin validation script
function checkId(o){
if(o.value!="")
for(i=0;i<o.value.length;i++){
if(!((o.value.charCodeAt(i)>=48&&o.value.charCodeAt(i)<=57)||(o.value.charCodeAt(i)>=65&&o.value.charCodeAt(i)<=90)||(o.value.charCodeAt(i)>=97&&o.value.charCodeAt(i)<=122)))
{
alert("ID只能由字母和数字组成!");
o.focus();
break;
}
}
}
function checkConfirm(o1,o2){
if(o2.value!=""){
if(o2.value!=o1.value){
alert("两次输入的密码必须相同!");
o1.focus();
}
}
}
function checkform2(){
if(document.form2.name.value==""){
alert("请输入姓名!");
return false;
}
else if(document.form2.pinyin.value==""){
alert("请输入姓名的拼音!");
return false;
}
else if(document.form2.no.value==""){
alert("请输入员工号码!");
return false;
}
else if(document.form2.id.value==""){
alert("请输入用户名!");
return false;
}
else if(document.form2.psw.value==""){
alert("请输入密码!");
return false;
}
else if(document.form2.repsw.value!=document.form2.psw.value){
alert("请正确输入密码");
return false;
}
else
return true;
}
// End of validation script -->

</script><script language="JavaScript">
<!--
function RgTest()
{
if(document.form1.userid.value=="")
{
window.alert("请输入用户名名称!");
document.form1.resource.focus();
return false;
}
if(document.form1.name.value=="")
{
window.alert("请输入真实姓名!");
document.form1.userid.focus();
return false;
}
if(document.form1.street.value=="")
{
window.alert("请完整输入信息!");
document.form1.userid.focus();
return false;
}
if(document.form1.city.value=="")
{
window.alert("请完整输入信息!");
document.form1.userid.focus();
return false;
}
if(document.form1.state.value=="")
{
window.alert("请完整输入信息!");
document.form1.userid.focus();
return false;
}
if(document.form1.zipCode.value=="")
{
window.alert("请完整输入信息!");
document.form1.userid.focus();
return false;
}
if(document.form1.phone.value=="")
{
window.alert("请完整输入信息!");
document.form1.phone.focus();
return false;
}
if(document.form1.email.value=="")
{
window.alert("请完整输入信息!");
document.form1.email.focus();
return false;
}
if(document.form1.cardNumber.value=="")
{
window.alert("请完整输入信息!");
document.form1.cardNumber.focus();
return false;
}
if(document.form1.password.value!=document.form1.confirmpassword.value)
{
window.alert("请正确输入密码!");
document.form1.password.focus();
return false;
}

return true;
}
//-->
</script>

<%
String userid = request.getParameter("userid");
if ( userid == null ) {
userid = "";
}
String email = request.getParameter("email");
if ( email == null ) {
email = "";
}
String name = request.getParameter("name");
if ( name == null ) {
name = "";
}
String phone = request.getParameter("phone");
if ( phone == null ) {
phone = "";
}
String street = request.getParameter("street");
if ( street == null ) {
street = "";
}
String city = request.getParameter("city");
if ( city == null ) {
city = "";
}
String state = request.getParameter("state");
if ( state == null ) {
state = "";
}
String zipCode = request.getParameter("zipCode");
if ( zipCode == null ) {
zipCode = "";
}
String cardNumber = request.getParameter("cardNumber");
if ( cardNumber == null ) {
cardNumber = "";

}

String errorMessage = request.getParameter("errorMessage");
%>
<%
if ( errorMessage != null ) {
%>
<span class="headingred">
<%=errorMessage%>
</span>
<br>
<%
}
%>

<form method="post" action="newuser.jsp" name="form1">
<table border="0" cellspacing="0" cellpadding="0" width="500">

<tr><td colspan="6"><IMG height=10 alt="" src="images/spacer.gif" width=1 border=0></td></tr>
<tr>
<td align="right"><IMG height=18 alt="" src="images/titlebar_left.gif" width=6 border=0></td>
<td background="images/titlebar_stretch.gif" valign="center"></td>
<td background="images/titlebar_stretch.gif" valign="center"></td>
<td background="images/titlebar_stretch.gif" valign="center"></td>
<td background="images/titlebar_stretch.gif" align="right" valign="center"></td>
<td><IMG height=18 alt="" src="images/titlebar_right.gif" width=6 border=0></td>
</tr>
<tr><td colspan="6"><IMG height=10 alt="" src="images/spacer.gif" width=1 border=0></td></tr>
<tr>
<td> </td>
<td> </td>

<td>用户名:</td>
<td><input size="15" name="userid" value=<%=userid%>></input></td>
<td> </td>
<td> </td>
</tr>
<tr><td colspan="6"><IMG height=3 alt="" src="images/spacer.gif" width=1 border=0></td></tr>
<tr>
<td> </td>
<td> </td>

<td>密码:</td>
<td><input type="password" size="15" name="password"></input></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>

<td>确认密码:</td>
<td><input type = "password" size="15" name="confirmpassword"></input></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>

...全文
166 点赞 收藏 15
写回复
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
tomwen 2004-11-04
求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!求救!!
回复
tomwen 2004-11-04
UserInfo.java

package com.jspdev.ch5;
import java.util.Date;
public class UserInfo
{
//属性
private String userid;
private String password;
private String email;
private String name;
private String street;
private String city;
private String state;
private String phone;
private String zipCode;
private String cardNumber;
private int cardType;
private Date expireDate;
private int userLogCount;
private int userType ;
private Date userLastLogTime;
private String fanvcategory;

//getter方法
public String getUserid()
{
return this.userid;
}

public String getPassword()
{
return this.password;
}

public String getName()
{
return this.name;
}

public String getPhone()
{
return this.phone;
}

public String getEmail()
{
return this.email;
}

public String getStreet()
{
return this.street;
}


public String getCity()
{
return this.city;
}

public String getState()
{
return this.state;
}

public String getZipCode()
{
return this.zipCode;
}

public String getCardNumber()
{
return this.cardNumber;
}
public int getCardType()
{
return this.cardType;
}

public String getFanvcategory()
{
return this.fanvcategory;
}


//setter方法
public void setUserid(String c)
{
this.userid=c;
}

public void setPassword(String c)
{
this.password=c;
}
public void setName(String c)
{
this.name=c;
}

public void setPhone(String c)
{
this.phone=c;
}

public void setEmail(String c)
{
this.email=c;
}

public void setStreet(String c)
{
this.street=c;
}

public void setCity(String c)
{
this.city=c;
}

public void setState(String c)
{
this.state=c;
}


public void setZipCode(String c)
{
this.zipCode=c;
}


public void setCardNumber(String c)
{
this.cardNumber=c;
}

public void setCardType(int c)
{
this.cardType=c;
}

public void setFanvcategory(String c)
{
this.fanvcategory=c;
}




}
回复
jjsspp001 2004-11-03
把UserInfo.java贴出来看看.
回复
tomwen 2004-11-03
求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!求救!
回复
zcjl 2004-11-03
/tomwen/newuser.jsp(3,0) The value for the useBean class attribute com.jspdev.ch5.UserInfo is invalid.

也许因为regist.setUserInfo(userInfo);中的userInfo不是合法的参数
回复
nortan 2004-11-03
和我的错误一样,也不明白,关注!
回复
tomwen 2004-11-03
那应该怎么办呀?朋友教教我
回复
tomwen 2004-11-02
<%@ page language="java" errorPage="error.jsp" import="com.jspdev.ch5.*"%>

<jsp:useBean id="userInfo" class="com.jspdev.ch5.UserInfo" scope="page">
<jsp:setProperty name="userInfo" property="*"/>
</jsp:useBean>
<jsp:useBean id="regist" class="com.jspdev.ch5.UserRegist" scope="page"/>
<html>
<head>
<title>用户信息注册</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<LINK href="hellking.css" type=text/css rel=stylesheet>
<body>
<%

regist.setUserInfo(userInfo);
regist.regist();
out.println("注册成功");
%>
<br>
<a href="main.jsp">返回</a>
</body>
</html>


回复
mendynew 2004-11-02
where's your useBean?
回复
mendynew 2004-11-02
useBean's problem
回复
tomwen 2004-11-02
5555555555555555555
回复
treeroot 2004-11-02
谁有勇气看这么多东西呀
回复
tomwen 2004-11-02
org.apache.jasper.JasperException: /tomwen/newuser.jsp(3,0) The value for the useBean class attribute com.jspdev.ch5.UserInfo is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:150)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1227)
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:3272)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:244)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:490)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:471)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:459)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


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

回复
tomwen 2004-11-02
UserRegist.java代码如下:
package com.jspdev.ch5;

import java.sql.*;

public class UserRegist
{
private UserInfo userInfo;
private Connection con;

//获得数据库连接。
public UserRegist()
{
String CLASSFORNAME="com.microsoft.jdbc.sqlserver.SQLServerDriver";
String SERVANDDB="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=jspdev";
String USER="sa";
String PWD="1980";
try
{

Class.forName(CLASSFORNAME);
con = DriverManager.getConnection(SERVANDDB,USER,PWD);
}
catch(Exception e)
{
e.printStackTrace();
}
}
//设置待注册的用户信息。
public void setUserInfo(UserInfo userInfo)
{
this.userInfo=userInfo;
}

//进行注册
public void regist()throws Exception
{
String reg="insert into user_Info values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";

try
{
PreparedStatement pstmt=con.prepareStatement(reg);
pstmt.setString(1,userInfo.getUserid());
pstmt.setString(2,userInfo.getName());
pstmt.setString(3,userInfo.getPhone());
pstmt.setString(4,userInfo.getStreet());
pstmt.setString(5,userInfo.getState());
pstmt.setString(7,userInfo.getCity());
pstmt.setString(6,userInfo.getZipCode());
pstmt.setString(8,userInfo.getEmail());
pstmt.setString(9,userInfo.getCardNumber());
pstmt.setInt(10,userInfo.getCardType());
pstmt.setInt(11,0);
pstmt.setDate(12,new java.sql.Date(new java.util.Date().getTime()));
pstmt.setInt(13,1);
pstmt.setInt(14,0);
pstmt.setString(15,userInfo.getFanvcategory());
pstmt.setString(16,userInfo.getPassword());
pstmt.executeUpdate();
}
catch(Exception e)
{
e.printStackTrace();
throw e;
}
}
}
回复
tomwen 2004-11-02
<td>真实姓名:</td>
<td><input size="15" name="name" value=<%=name%>></input></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>电话:</td>
<td><input size="15" name="phone" value=<%=phone%>></input></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>email:</td>
<td><input size="15" name="email" value=<%=email%>></input></td>
<td> </td>
<td> </td>
</tr>

<tr>
<td> </td>
<td> </td>

<td>街道:</td>
<td><input size="15" name="street" value=<%=street%>></input></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="18"> </td>
<td> </td>

<td>城市:</td>
<td><input size="15" name="city" value=<%=city%>></input></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>

<td>省:</td>
<td><input size="15" name="state" value=<%=state%>></input></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>

<td>邮编:</td>
<td><input size="15" name="zipCode" value=<%=zipCode%>></input></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>信息卡信息:</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>卡号:</td>
<td><input size="15" name="cardNumber" value=<%=cardNumber%>></input></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>开户银行:</td>
<td><select size="1" name="cardType">
<option value="01">建设银行</option>
<option value="02">工商银行</option>
<option value="03">交通银行</option>
<option value="04">农业银行</option>
<option value="05">招商银行</option>
</select></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>个人定制信息:</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>喜欢的图类别:</td>
<td

<select name="fanvcategory">
<%
Class.forName(CLASSFORNAME);
Connection con = DriverManager.getConnection(SERVANDDB,USER,PWD);
Statement statement=con.createStatement();
ResultSet rst=statement.executeQuery("select * from category");
while(rst.next())
{
out.println(trans("<option value="+rst.getString("catid")+">"+rst.getString("name")+"</option>"));
}
con.close();
%>
</select>
</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>是否需要在提供购物时的提示:</td>
<td><input size="15" name="banneropt" type="checkbox" ></input></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td></td>
<td><input type="image" src="image/loginsubmit.gif" name="submit" onClick="return RgTest()"></input></td>
<td> </td>
<td> </td>
</tr>
</table>
<td><IMG height=3 alt="" src="image/spacer.gif" width=1 border=0>

</form>



</tr>
</table>

</body>
</html>
回复
发动态
发帖子
Web 开发
创建于2007-09-28

7.9w+

社区成员

Java Web 开发
申请成为版主
社区公告
暂无公告