sort_add.jsp的46行,可能有个变量是null

解决方案 »

  1.   

    这是我的代码<%@ page contentType="text/html; charset=gb2312" %>
    <%@include file="../../pub/WuserSession.jsp"%>
    <%
    /*添加和修改图片所属栏目分类的jsp页面
    **2005.5.18
    *///StrID 用来判断是否有记录String StrID = (String)request.getParameter("st_sortID");//StrOperation用来判断对数据库做什么操作String StrOperation = (String)request.getParameter("opt");String st_sortTitle="",st_sortMemo="" ,st_sortID="";//StrID==null进行添加操作 StrID!=null修改操作if(StrID!=null){    
    if(StrOperation.equals("update")){//修改提交
    String strSql = "update KL_SortTable set ";
    strSql += " st_sortTitle='"+ request.getParameter("st_sortTitle") +"'"
       + ",st_sortMemo='"+ request.getParameter("st_sortMemo") +"'"
       + " where st_sortID="+StrID;
    int i=dbquery.executeUpdate(strSql);
    out.println("<script language='javascript'>");
    out.println("location='sort_add.jsp'");
    out.println("</script>");
    out.flush();
    }else{
    String strSql = "select * from KL_SortTable where st_sortID="+ StrID; 
    ResultSet rs = dbquery.executeQuery(strSql);
    if(rs.next()){
    st_sortTitle=rs.getString("st_sortTitle");
    st_sortMemo=rs.getString("st_sortMemo");
    rs.close();
    rs=null;
    }
    if(rs!=null)rs=null;
    dbquery.stmtcls();
    }
    }
    else{
         if(StrOperation.equals("insert")){//新增提交
        String strSql = "insert into KL_SortTable (st_sortTitle,st_sortMemo)";
    strSql += " values('"+ request.getParameter("st_sortTitle") +"','"
           + request.getParameter("st_sortMemo") +"')";
    int i=dbquery.executeUpdate(strSql);
    out.println("<script language='javascript'>");
    out.println("location='sort_add.jsp';");
    out.println("</script>");
    out.flush();
    }
    }
    %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head><body>
    <p align="center">新增图片栏目
    </p>
    <form name="form_add_update_sort" method="post" action="sort_add.jsp">
      <div align="center">
        <table width="60%" height="363" border="1" bordercolor="#9900FF">
          <caption>&nbsp;
      </caption>
          <tr>
            <th width="74" height="46" scope="row">栏目标题</th>
            <td width="306">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

    <input name="st_sortTitle" type="text" id="st_sortTitle" value="<%=st_sortTitle%>" maxlength="50"></td>
          </tr>
          <tr>
            <th height="233" scope="row">栏目说明</th>
            <td nowrap bordercolor="#9966FF">
              <div align="left">
                <blockquote>
                  <blockquote>
                    <p name="textarea" rows="10">
                      <textarea name="st_sortMemo" rows="10" id="st_sortMemo"><%=st_sortMemo%></textarea>
                    </p>
                  </blockquote>
                </blockquote>
            </div></td>
          </tr>
          <tr>
              <td><%if(StrID!=null){ %>
    <input name="Submit1" type="submit" class="input_g" value="确定">
    <input name="id" type="hidden" value="<%=st_sortID%>">
    <input name="opt" type="hidden" value="update"> 
    <%
     }else{
    %> 
    <input name="Submit2" type="submit" class="input_g" value="保存">
    <input name="opt" type="hidden" value="insert"> <%
     }%></td>
                <td><input name="Submit3" type="button" class="input_g" value="取消" onclick="javascript:history.back();"></td>
          </tr>
        </table>
    </div>
      <div align="center"></div>
    </form>
    <p>&nbsp; </p>
    </body>
    </html>