JSP下session传值问题 先谢谢了!
我在修改密码页面下:
<%@include file="inc/dbsfunc.jsp"%>
<font color="#FF3300">级别:</font></font></font> <font color="#006699"><%=GetGradeName(session.getAttribute("grade"));%>
提示这个错误:Syntax error on token ";", delete this token
inc/dbsfunc.jsp页面下的类:
class myFunction{
//取得设备名称
void GetDevName(Object DeviceId){
String GetDevName;
Statement st_DeviceCode;
st_DeviceCode=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql_DeviceCode="select count(*) coun from DeviceCode where DeviceId like'"+Trim(DeviceId) +"'" ;
ResultSet rs_DeviceCode=st_DeviceCode.executeQuery(sql_DeviceCode);
int Count=rs_DeviceCode.getInt(coun);
if(Count>0)
GetDevName =( "未知设备(" + DeviceId + ")");
else
GetDevName = Trim(rs_DeviceCode("DeviceName"));
rs_DeviceCode.close();
}
}
提示:Cannot refer to a non-final variable conn inside an inner class defined in a
different method
不知道错在哪,刚接触JSP 请大家指教下怎么修改
[解决办法]
很明显你脚本段里面<%=.....%>里面的分号是不需要的!
[解决办法]
java表达式里面不需要分号
[解决办法]
class myFunction{
//取得设备名称
void GetDevName(Object DeviceId){
String GetDevName;
Statement st_DeviceCode;
st_DeviceCode=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql_DeviceCode="select count(*) coun from DeviceCode where DeviceId like'"+Trim(DeviceId) +"'" ;
ResultSet rs_DeviceCode=st_DeviceCode.executeQuery(sql_DeviceCode);
int Count=rs_DeviceCode.getInt(coun);
if(Count>0)
GetDevName =( "未知设备(" + DeviceId + ")");
else
GetDevName =trim(rs_DeviceCode.getString("DeviceName"));
rs_DeviceCode.close();
}
}
coun 没有定义 conn没有定义,估计是<%@include file="inc/dbsfunc.jsp"%>未引入,或者是这个jsp本身就有问题
[解决办法]
看楼主的写法太像phper了、这看的我都有点蒙了、