📄 modifyshopcaraction.java
字号:
package omega.struts.action.shopcar;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import omega.domain.Member;
import omega.domain.Shopcart;
import omega.logic.ShopCarLogic;
import omega.logic.shopping.ShopLogic;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.validator.DynaValidatorForm;
public class ModifyShopCarAction extends Action {
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
DynaValidatorForm dyform=(DynaValidatorForm)form;
HttpSession session=request.getSession();
// if(session.getAttribute("member")==null){
// return mapping.findForward("false");
// }else{
ShopCarLogic sl=new ShopCarLogic();
String[] id=(String[])dyform.get("id");
String[] productid=(String[])dyform.get("productid");
String[] count=(String[])dyform.get("count");
String[] saleprice=(String[])dyform.get("saleprice");
String[] price=(String[])dyform.get("price");
String[] productname=(String[])dyform.get("productname");
String[] del=(String[])dyform.get("del");
Member m=(Member)session.getAttribute("member");
String username=m.getUsername();
for(int i=0;i<id.length;i++){
Shopcart sc=new Shopcart();
sc.setId(Integer.parseInt(id[i]));
sc.setOrderid(0);
sc.setCount(Integer.parseInt(count[i]));
sc.setProductid(Integer.parseInt(productid[i]));
sc.setProductname(productname[i]);
sc.setSaleprice(Integer.parseInt(saleprice[i]));
sc.setUsername(username);
sc.setPrice((Integer.parseInt(count[i]))*(Integer.parseInt(saleprice[i])));
sl.update(sc);
}
if(del!=null){
for(int i=0;i<del.length;i++){
sl.Del(Integer.parseInt(del[i]));
}
}
List sc=sl.getCarbyName(username);
request.setAttribute("shopcar", sc);
// }
return mapping.findForward("success");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -