⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 showcartaction.java

📁 基于Struts的网络商店源码。使用Hibernate技术
💻 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.IWebStoreFacade;
import com.sush.webstore.store.domain.facade.WebStorePOJO;

public class ShowCartAction {

	private IWebStoreFacade webStore = new WebStorePOJO();

	private ICart cart;

	public String execute() {

		if (!loadOrCreateCart())
			return "error";
		return "success";
	}

	/**
	 * @return the cart
	 */
	public boolean loadOrCreateCart() {

		Map session = (Map) ActionContext.getContext().get("session");

		if (session == null) {
			return false;
		}

		cart = (ICart) session.get("cart");

		if (cart == null) {
			cart = webStore.createCart();
			session.put("cart", cart);
		}
		return true;
	}

	/**
	 * @return the cart
	 */
	public ICart getCart() {
		return cart;
	}

	/**
	 * @param cart
	 *            the cart to set
	 */
	public void setCart(ICart cart) {
		this.cart = cart;
	}

	/**
	 * @return the webStore
	 */
	public IWebStoreFacade getWebStore() {
		return webStore;
	}

	/**
	 * @param webStore
	 *            the webStore to set
	 */
	public void setWebStore(IWebStoreFacade webStore) {
		this.webStore = webStore;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -