同时还有这个错误
 ';' expected
editor_forum_id[]=(String)session.getAttribute("editor_forum_id");//

解决方案 »

  1.   

    editor_forum_id=(String[])session.getAttribute("editor_forum_id");
      

  2.   


       楼上正解,显式转换应该是(String[]);另';' expected的意思是,你的程序某处漏掉了分号,或语法格式错误。
      

  3.   

    哈谢谢对了。。能否讲解一下java字符串数组问题。。
    给一个字符串赋值要新建一个对象。。那给一个字符串数组赋值呢?
     new String[x1,x2,x3];?
      

  4.   

    对了显式变化也是这样。。
     not a statement
    editor_forum_id[]=(String[])session.getAttribute("editor_forum_id");//
    我现在怀疑是我的session赋值问题
      

  5.   

    新建字符串数组并给字符串数组赋值应该为String[] x=new String[]{"sdf","sdkf"};
      

  6.   

    恩。。那在session里面添加数组是怎么样呢?
    String[] e=new String[]("1","2","3");
    setAttribute("edit",e);
    这样写对吗?e要不要加引号?
      

  7.   

    request.getSession().setAttribute(("edit",e);是正确的。
      

  8.   

    第一个页面 makesession.jsp
    <%
    String e[]=new String[]{"2","3","4"};session.setAttribute("user_right","1");
      session.setAttribute("user_login","true");
      session.setAttribute("editor_forum_id",e);
    %>
    <html>
    <head>
    <title>makesession</title></head>
    <body>
    <form method="post"action="DeleteTopic.jsp">
    <p>板块id
    <input type="text"name="forumid">
    <p>帖子id
    <input type="text"name="topicid">
    <input type="submit"name="submit"value="提交">
    </form>
    </body>
    </html>
      

  9.   

    第2个页面DeleteTopic.jsp<%@ page contentType="text/html;charset=gb2312" language="java"
    import="java.sql.*,java.io.*"errorPage="error.jsp"%>
    <html>
    <head>
    <title>生成session和判断权限</title></head>
    <body>
    <% String forumid="";// 板块id
    String user_right="";//用户权限
    String user_islogin="";//是否登陆
    String[] editor_forum_id=new String[10];//斑竹管理的板块
    int user_right_int=0;//初始化
    int editor_forum_id_int[]=new int[10];//初始化
    forumid=request.getParameter("forumid");
    user_right=(String)session.getAttribute("user_right");
    user_islogin=(String)session.getAttribute("user_login");
    editor_forum_id[]=(String[])session.getAttribute("editor_forum_id");//从session中取得斑竹管理的板块值 
    user_right_int=Integer.parseInt(user_right);//将用户权限转为整形
    for(int i=0;i<editor_forum_id.length;i++)//将斑竹管理的板块转成整形
    {
       editor_forum_id_int[i]=Integer.parseInt(editor_forum_id[i]);
    }
    if(user_islogin.equals("no"))//如果没有登陆,就跳出
       response.sendRedirect("error.jsp?message=1");
    if(user_right.equals("2"))//如果用户权限为普通用户。就没有权限删除帖子
       response.sendRedirect("error.jsp?message=2");
    if(user_right.equals("1"))//如果用户权限为斑竹,就执行下面的操作
       {
        for(int i=0;i<editor_forum_id_int.length;i++)//如果斑竹管理的板块是该帖子的板块,就执行下面的操作
       { 
    if(editor_forum_id_int[i]==forumid)
          response.sendRedirect("delete.jsp");
       }
         response.sendRedirect("error.jsp?message=2");//否则跳出
        } 
    else
    response.sendRedirect("delete.jsp");//如果用户权限不是普通用户或是斑竹。。那就一定是管理员。执行delete操作。%>
    </body>
    </html>
      

  10.   

    editor_forum_id[]=(String[])session.getAttribute("editor_forum_id");
    应该为:
    editor_forum_id=(String[])session.getAttribute("editor_forum_id");//
      

  11.   

    恩。。谢谢。。还没注意到呢
    对了。
    错误:operator == cannot be applied to int,java.lang.String
    if(editor_forum_id_int[i]==forumid)
    是什么意思。。
    命名时不能用int吗?