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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

刪除后為什么頁面沒有反應(yīng)啊

點(diǎn)擊刪除按鈕,然后頁面鏈接是http://localhost:8080/JspDEMO/CartServlet?action=delete&id=3。

但頁面的商品沒有被刪除。

private boolean delete(HttpServletRequest request, HttpServletResponse response){

String id=request.getParameter("id");

Cart cart=(Cart) request.getSession().getAttribute("cart");

items item=items.getById(Integer.parseInt(id));

if(cart.delect(item)){

return true;

}else{

return false;

}

}


if(action.equals("delete")){

if(delete(request,response)){

request.getRequestDispatcher("/cart.jsp").forward(request, response);

}

}

<a href="CartServlet?action=delete&id=<%=i.getId()%>" onclick="delect()">刪除</a>


正在回答

2 回答

問題已經(jīng)解決。equals重寫有問題。

if(obj instanceof items){

items i=(items) obj;

if(this.getId()==i.getId()&&this.getName().equals(i.getName())){

return true;

}else{

return false;

}

}else{

return false;

}

這樣寫就好。原本老師是==判斷this.getName()。這樣只判斷是否是同一對(duì)象。

但改成this.getName().equals(i.getName())就判斷是否完全相等。

0 回復(fù) 有任何疑惑可以回復(fù)我~

有沒有人啊

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

刪除后為什么頁面沒有反應(yīng)啊

我要回答 關(guān)注問題
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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