📄 itemopeaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.shopping.struts.action.item;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.shopping.dao.UnifyDao;
import com.shopping.factory.DAOFactory;
import com.shopping.vo.Item;
/**
* MyEclipse Struts
* Creation date: 04-29-2008
*
* XDoclet definition:
* @struts.action parameter="action" validate="true"
*/
public class ItemOpeAction extends DispatchAction {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward modify(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
UnifyDao itemDao = null;
try {
itemDao = (UnifyDao) DAOFactory
.getBean("com.shopping.dao.imp.ItemDaoImp");
} catch (InstantiationException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IllegalAccessException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
int id = Integer.parseInt(request.getParameter("id"));
double price = Double.parseDouble(request.getParameter("price"));
Item item = (Item)itemDao.getTableById(id);
item.setPrice(price);
if(itemDao.updateTable(item)) System.out.print("updateSuccess");
response.setContentType("text/html;charset=gbk");
response.setHeader("Cache-Control", "no-store"); //HTTP1.1
response.setHeader("Pragma", "no-cache"); //HTTP1.0
response.setDateHeader("Expires", 0);
return null;
}
public ActionForward deleteAll(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
UnifyDao itemDao = null;
try {
itemDao = (UnifyDao) DAOFactory
.getBean("com.shopping.dao.imp.ItemDaoImp");
} catch (InstantiationException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IllegalAccessException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
String[] ids = request.getParameterValues(":deleteCheckbox");
if(ids!=null&&ids.length>0){
for(int i=0;i<ids.length;i++){
int id = Integer.parseInt(ids[i]);
itemDao.deleteTableById(id);
}
}
return new ActionForward("/admin/item.do?action=all");
}
public ActionForward delete(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
UnifyDao itemDao = null;
try {
itemDao = (UnifyDao) DAOFactory
.getBean("com.shopping.dao.imp.ItemDaoImp");
} catch (InstantiationException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IllegalAccessException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
int id = Integer.parseInt(request.getParameter("id"));
itemDao.deleteTableById(id);
return new ActionForward("/admin/item.do?action=all");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -