为什么jsp中使用session.getAttribute()出错

来源:百度知道 编辑:UC知道 时间:2024/05/17 08:28:45
An error occurred at line: 29 in the jsp file: /loginModule/topMain.jsp
Syntax error on token ")", } expected
26: </td>
27: <td>
28: <%
29: if(session.getAttribute("accessable")!=null)
30: {
31: access=java.lang.Boolean.valueOf(session.getAttribute("accessable"));
32: if(access==true)

JSP FileName:null
Java FileName:/C:/Program Files/Apache Software Foundation/Tomcat 5.5/work/Catalina/localhost/myApps//org/apache/jsp/loginModule\topMain_jsp.java

少了还不止一个口号咧
28行的 <% 没有反括号
30行的 { 也没有反括号;
if(session.getAttribute("accessable")!=null)
{
access=java.lang.Boolean.valueOf(session.getAttribute("accessable"));
if(access==true)

你这里的代码也写得有问题:
session.getAttribute("accessable")是取值你判断了是否为空。而你又在后面又将它转化为了一个 boolean 的类型赋值给了个 access 的变量 access=java.lang.Boolean.valueOf(session.getAttribute("accessable"));

boolean只是个标记的类型的变量
你可以这样:
boolean falg = false;
String access = null;//定义跟accessable类型一样;
29: if(session.getAttribute("accessable")!=null)
30: {
31: access = session.getAttribute("accessable");
falg = true;
}
32: if(falg==true)
{
// 继续你的下面的操作;
}

你少个花括号吧