📄 signoutaction.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;
import com.sush.webstore.store.domain.IUserAccount;
public class SignOutAction {
public String execute() {
if (getUserFromSession() != null)
removeUserFromSession();
else
return "error";
if (getCartFromSession() != null)
removeCartFromSession();
if (getOrderFromSession() != null)
removeOrderFromSession();
return "success";
}
/**
* @return the cart
*/
private ICart getCartFromSession() {
Map session = (Map) ActionContext.getContext().get("session");
if (session == null) {
return null;
}
return (ICart) session.get("cart");
}
/**
* @return the cart
*/
private boolean removeCartFromSession() {
Map session = (Map) ActionContext.getContext().get("session");
if (session == null) {
return false;
}
session.put("cart", null);
return true;
}
/**
* @return the cart
*/
private IUserAccount getUserFromSession() {
Map session = (Map) ActionContext.getContext().get("session");
if (session == null) {
return null;
}
return (IUserAccount) session.get("userAccount");
}
/**
* @return the cart
*/
private boolean removeUserFromSession() {
Map session = (Map) ActionContext.getContext().get("session");
if (session == null) {
return false;
}
session.put("userAccount", null);
return true;
}
private IOrder getOrderFromSession() {
Map session = (Map) ActionContext.getContext().get("session");
if (session == null) {
return null;
}
return (IOrder) session.get("order");
}
private 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 + -