📄 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");
//进行数据库中删除操作
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 自动生成方法存根
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -