首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

编译不通过,请大家帮小弟我看下

2012-01-02 
编译不通过,请大家帮我看下%@pagecontentType text/htmlcharsetgb2312 language java import j

编译不通过,请大家帮我看下
<%@page   contentType= "text/html;   charset=gb2312 "   language= "java "   import= "java.sql.* "   errorPage= " "   %>
<html>
<head>
<title> reply </title>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 ">
</head>
<jsp:useBean   id= "jezz_mj_reply "   scope= "page "   class= "wm.bean.DB "   />
<body>
<%
    String   login   =   (String)session.getAttribute( "login ");
    String   error= " ";
    String   id=request.getParameter( "id ");
    /*String   sql= "select   content   from   liuyan_temp   where   id= "+id;
      ResultSet   rs=jezz_mj_reply.executeQuery(sql);
      rs.next();
      String   content=rs.getString( "content ");*/
    //String   httpfile= " ";
    //httpfile=request.getHeader( "REFERER ");
      if(login==null)
      error+= "非法操作 ";
      if(id== " ")
      error+= "非法回复 ";
      if(error.equals( " "))
      {

      String   sql= "select   content   from   liuyan_temp   where   id= "+id;
      ResultSet   rs=jezz_mj_reply.executeQuery(sql);
      rs.next();
      String   content=rs.getString( "content ");
                     


        }
else
{
out.print(error);
//response.sendRedirect( "index.jsp ");
}
%>

<form   action= "reply "   method= "post "   name= "rform ">
<table   width= "500 "   border= "0 "   align= "center ">
    <tr>
        <td   align= "center "> 回复留言 </td>
    </tr>
    <tr>
        <td   align= "center "> <textarea   name= "content "   cols= "60 "   rows= "10 "> <%=content%>   </textarea> &nbsp; </td>
    </tr>
    <tr>
        <td   align= "center "> <textarea   name= "content_reply "   cols= "60 "   rows= "10 "> </textarea> </td>
    </tr>
    <tr>
        <td   align= "center "> <input   name= "sumit "   type= "submit "   value= "提交 "> </td>
    </tr>
</table>
</form>
<%
  //rs.close();
  jezz_mj_reply.all_close();
%>
</body>
</html>
出错是这个地方 <%=content%> ,提示是这样的content   cannot   be   resolved
不知道我的哪个地方出错了

------解决方案--------------------


String content=rs.getString( "content ");你这个content放在if(error.equals( " "))这个if里面,当if完了,content的作用域就完了,看看基础知识:
改成:
String content=null;
if(error.equals( " "))
{
//其余代码
content=rs.getString( "content ");
//其余代码
}
[解决办法]
明显是作用域的问题。
如果你整个页面都需要用这个变量的话,建议声明成变量
<%!String conten=null;%>

热点排行