当前位置: 代码迷 >> Java Web开发 >> Cannot cast from Object to int 是什么有关问题
  详细解决方案

Cannot cast from Object to int 是什么有关问题

热度:1019   发布时间:2016-04-17 00:26:19.0
Cannot cast from Object to int 是什么问题?
<%@ page contentType="text/html;charset=gb2312" language="java"%>
<%@ page import="java.sql.*"%>
<!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=gb2312">
<title>用户手册</title>
<script language="javascript">
function chkEmail(str)
{
return
str.search(/[\w\-]{1,}@[\w\-]{1,}\.[\w\-]{1,}/)==0?true:false
}
function check_info()
{
if(form1.NickName.value=="")
{
alert("请填写昵称");
return false;
}
else if(form1.Email.value=="")
{
alert("请填写邮箱");
return false;
}
else if(!chkEmail(form1.Email.value))
{
alert("请填写有效的Email地址")
return false;
}
else
{
return true;
}
}
function check_password()
{
if(form2.OldUserPassword.value=="")
{
alert("请填写旧密码");
return false;
}
else if(form2.UserPassword.value=="")
{
alert("请填写新密码");
return false;
}
else if(form2.UserPassWord.value!=form2.CUserPassword.value)
{
alert("确认密码与新密码不一致")
return false;
}
else 
{
return true;
}
}
</script>
</head>
<body>
<%
int l_UserID=0;
try
{
l_UserID=(int) session.getAttribute("UserID");//问题出在这里啊..................看这里。。。。。。。。。。



}
catch(NumberFormatException ex)
{}
if(l_UserID!=0)
{
String strSql="";
String database_username="sa";
String database_password="sa";
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=ZYGL";
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
Connection dbConn=DriverManager.getConnection(url,database_username,database_password);
Statement stmt=dbConn.createStatement();
strSql="select * from users where UserID="+l_UserID;
ResultSet rs=stmt.executeQuery(strSql);
if(rs.next())
{
%>
<div align="center">
<h1 align="center">修改用户资料</h1>
<form name="form1" action="modify_info.jsp" method="post" target="_self" 
onSubmit="return check_info()">
<table width="80%" border="0">
<tr>
<td align="right" width="50%" bgcolor="#CCCCCC" height="25">用户名:</td>
<td align="left" width="50%" height="25">&nbsp;
<input type="text" name="UserName" value=<%=rs.getString("UserName")%>></td>
</tr>

<tr>
<td align="right" width="50%" bgcolor="#CCCCCC" height="25">昵称:</td>
<td align="left" width="50%" height="25">&nbsp;
<input type="text" name="NickName" value=<%=rs.getString("NickName")%>></td>
</tr>

<tr>
<td align="right" width="50%" bgcolor="#CCCCCC" height="25">性别:</td>
<td align="left" width="50%" height="25">&nbsp;
<input type="radio" name="Sex" <%if(rs.getInt("Sex")==0)
  相关解决方案