📄 clearcartandorderaction.java
字号:
package com.sush.webstore.store.web.struts;
import java.util.Map;
import com.opensymphony.xwork2.ActionContext;
import com.sush.webstore.store.domain.ICart;
import com.sush.webstore.store.domain.IOrder;
public class ClearCartAndOrderAction {
public String execute() {
if (getCartFromSession() != null)
removeCartFromSession();
if (getOrderFromSession() != null)
removeOrderFromSession();
return "success";
}
/**
* @return the cart
*/
public ICart getCartFromSession() {
Map session = (Map) ActionContext.getContext().get("session");
if (session == null) {
return null;
}
return (ICart) session.get("cart");
}
private IOrder getOrderFromSession() {
Map session = (Map) ActionContext.getContext().get("session");
if (session == null) {
return null;
}
return (IOrder) session.get("order");
}
/**
* @return the cart
*/
public boolean removeCartFromSession() {
Map session = (Map) ActionContext.getContext().get("session");
if (session == null) {
return false;
}
session.put("cart", null);
return true;
}
/**
* @return the cart
*/
public boolean removeOrderFromSession() {
Map session = (Map) ActionContext.getContext().get("session");
if (session == null) {
return false;
}
session.put("order", null);
return true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -