?? delproductservlet.java
字號:
?
package adminshop;
import java.io.IOException;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public final class DelProductServlet extends HttpServlet{
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
Integer productId = (Integer)req.getAttribute("Id");
//進(jìn)行數(shù)據(jù)庫中刪除操作
DB db=new DB();
shopadmin sa=new shopadmin();
try {
Product product = sa.getProduct(db, productId.intValue());
sa.delete(product);
} catch (Exception e) {
// TODO 自動生成 catch 塊
e.printStackTrace();
}
//ActionMessages errors = new ActionMessages();
ArrayList error = null;
error.add(ActionMessages.GLOBAL_MESSAGE,
new ActionMessages("label.delOk"));
if (!error.isEmpty()) {
saveErrors(req, error);
}
resp.sendRedirect("toWrong");
}
private void saveErrors(HttpServletRequest req, ArrayList error) {
// TODO 自動生成方法存根
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -