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

📄 productswitchaction.java

📁 巴巴运动网源码 传智博客出品 不全 一部分代码 可以参考
💻 JAVA
字号:
package com.itcast.web.action.product;

import javax.annotation.Resource;
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 org.springframework.stereotype.Controller;

import com.itcast.service.product.ProductInfoService;
import com.itcast.utils.WebUtil;
import com.itcast.web.formbean.product.FrontProductForm;

@Controller("/product/switch")
public class ProductSwitchAction extends DispatchAction {
	@Resource(name="productInfoServiceBean")
	private ProductInfoService productInfoService;
	
	/**
	 * 显示产品大图片
	 */
	public ActionForward showimage(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws Exception {
		return mapping.findForward("showimage");
	}
	
	/**
	 * 获取10个最畅销的产品
	 */
	public ActionForward topsell(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws Exception {
		FrontProductForm formbean = (FrontProductForm) form;
		request.setAttribute("topsellproducts", productInfoService.getTopSell(formbean.getTypeid(), 10));
		return mapping.findForward("topsell");
	}
	
	/**
	 * 获取10个用户浏览过的产品
	 */
	public ActionForward getViewHistory(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws Exception {
		String cookieValue = WebUtil.getCookieByName(request, "productViewHistory");
		if(cookieValue!=null && !"".equals(cookieValue.trim())){			
			String[] ids = cookieValue.split("-");
			Integer[] productids = new Integer[ids.length];
			for(int i=0 ;i<ids.length; i++){
				productids[i]=new Integer(ids[i].trim());
			}
			request.setAttribute("viewHistory", productInfoService.getViewHistory(productids, 10));
		}
		return mapping.findForward("viewHistory");
	}
}

⌨️ 快捷键说明

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