我的登陆程序如下
<%@ page language= "java " contentType= "text/html;charset=GBK " %>
<%@ page import= "webapp.DBUtil,
webapp.SpConstants,
java.sql.* "%>
<%
String LoginName=request.getParameter( "usernameshow ").trim();
String strpws=request.getParameter( "pwshow ").trim();
ResultSet rs =null;
try
{
rs=DBUtil.exeupdate( "select Password,UserID from tbusers where LoginName= ' "+LoginName+ " ' ");
if(rs.next())
{
String pwd=rs.getString( "Password ").trim();
String userid=rs.getString( "UserID ").trim();
if(strpws.equals(pwd))
{
session.setAttribute(SpConstants.USERID_KEY,userid);
session.setAttribute(SpConstants.LOGINNAME,LoginName);
response.sendRedirect( "index_lg.jsp ");
}
else
{
out.print( " <script> ");
out.print( "alert( '密码错误! '); ");
out.print( "history.back(); ");
out.print( " </script> ");
}
}
else
{
out.print( " <script> ");
out.print( "alert( '该用户不存在! '); ");
out.print( "history.back(); ");
out.print( " </script> ");
}
}
catch(Exception e)
{
out.print( " <script> ");
out.print( "alert( '数据库错误! '); ");
out.print( "history.back(); ");
out.print( " </script> ");
}
finally
{
rs.close();
}
%>
为什么提示说找不到符号
符号: 变量 LOGINNAME
位置: 接口 webapp.SpConstants
session.setAttribute(SpConstants.LOGINNAME,LoginName);
但是同样都是webapp.SpConstants里的,USERID_KEY就可以找到。为什么呢???
------解决方案--------------------
仔细检查一下SpConstants,八成问题还在这里。
------解决方案--------------------
LOGINNAME
===================
没有,你把USERID_KEY拷一份,改成LOGINNAME
------解决方案--------------------
SpConstants.LOGINNAME常量问题。
检查一下导入的包: <%@ page import= "webapp.SpConstants>