第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

修改數(shù)據(jù)時,頁面正常跳轉(zhuǎn),但是實際數(shù)據(jù)并沒有修改

修改數(shù)據(jù)時,頁面正常跳轉(zhuǎn),但是實際數(shù)據(jù)并沒有修改

犯罪嫌疑人X 2019-04-19 13:15:17
小白,用的MyEclipse,jdbc鏈接的數(shù)據(jù)庫,增刪改查除了修改都可以實現(xiàn)。修改時,未提示代碼錯誤,而且頁面也可以正常跳轉(zhuǎn),但是數(shù)據(jù)沒有修改成功,依然是之前的數(shù)據(jù)。具體代碼如下:dao:public void updateNotice(NoticeBean nb)  {         Connection conn = DBUtil.getConnectDb();         String sql = "update gonggao set notice = ? where id =?";         PreparedStatement stm = null;         try {             stm = conn.prepareStatement(sql);             stm.setString(1, nb.getNotice());             stm.setInt(2, nb.getId());             stm.executeUpdate();         } catch (SQLException e) {             // TODO Auto-generated catch block             e.printStackTrace();         }     }servlet:protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {         // TODO Auto-generated method stub         request.setCharacterEncoding("UTF-8");         response.setContentType("text/html;charset=UTF-8");         int id = Integer.parseInt(request .getParameter("id"));         String notice = request.getParameter("notice");         System.out.println(notice);//可以在console看到修改的數(shù)據(jù)         NoticeBean nb = new NoticeBean();         NoticeDao dao = new NoticeDao();         try {             dao.updateNotice(nb);             response.sendRedirect("admain.jsp");         } catch (Exception e1) {             e1.printStackTrace();         }     }jsp:<form action="UpdateNo" method="post"> <table style="position: relative; left: 50%" class="table"> <% NoticeBean nb = (NoticeBean)request.getAttribute("nb"); %> <tbody>   <tr class="row1">    <td valign="middle" align="center">    <input type="hidden" name="id" value="<%=nb.getId() %>"/>    </td>    <td><input type="text" class="inputgri" name="notice" style="width: 800px;height: 80px;" value="<%=nb.getNotice() %>"/>    </td>                                   </tr> </tbody> </table> <button style="width: 30%; height: 35px; position: relative; top: -20px;right:20px"type="submit" value="提交" />                     提交                 </form>
查看完整描述

2 回答

?
慕俠2389804

TA貢獻(xiàn)1719條經(jīng)驗 獲得超6個贊

  String notice = request.getParameter("notice");
        System.out.println(notice);//可以在console看到修改的數(shù)據(jù)
        NoticeBean nb = new NoticeBean();        這里沒有數(shù)據(jù),    你的notice也沒有添加進(jìn)實體類。
        NoticeDao dao = new NoticeDao();
        try {
            dao.updateNotice(nb);       //相當(dāng)于傳了空對象
            response.sendRedirect("admain.jsp");
        } catch (Exception e1) {
            e1.printStackTrace();
        }


查看完整回答
反對 回復(fù) 2019-05-14
?
Helenr

TA貢獻(xiàn)1780條經(jīng)驗 獲得超4個贊

1、在dao層打斷點
2、sql執(zhí)行了沒有
3、事務(wù)是否提交了

查看完整回答
反對 回復(fù) 2019-05-14
  • 2 回答
  • 0 關(guān)注
  • 728 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號