首页>代码>spring+spring mvc+mybatis+mysql+maven整合开发服装购物商城实例>/shop/src/main/java/com/zgzcwy/controller/HomeController.java
package com.zgzcwy.controller;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.zgzcwy.entity.Category;
import com.zgzcwy.entity.Product;
import com.zgzcwy.service.CategoryService;
import com.zgzcwy.service.ProductService;

/**
 * @ClassName:  HomeController   
 * @Description:   进入网站主页的控制器
 * @author: Administrator  
 * @date:   2017年12月28日 下午4:25:15   
 *
 */
@Controller
public class HomeController{
	@Autowired 
	private CategoryService categoryService;
	@Autowired
	private ProductService productService;
	//热门商品的集合
	private List<Product> hotList;
	//最新商品集合
	private List<Product> newList;
	/**
	 * 首页访问的方法
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("/index")
	public String index(HttpSession session,Model model) throws Exception{
		//1.查询所有一级分类
		List<Category> categoryList = categoryService.findAllCategory();
		//2.将查询出来的所有存入session
		session.setAttribute("categoryList", categoryList);
		//查询热门商品
		hotList=productService.findAllHotProduct();
		model.addAttribute("hotList", hotList);
		//查询最新商品
		newList=productService.findAllNewProduct();
		model.addAttribute("newList", newList);
		return "index";
	}
	/**
	 * 跳转到注册页面
	 * @return
	 */
	@RequestMapping("/userRegist")
	public String userRegist() throws Exception{
		return "regist";
	}
	/**
	 * 跳转到激活页面
	 */
	@RequestMapping("/message")
	public String message() throws Exception{
		return "msg";
	}
	/**
	 * 跳转到用户登录页面
	 */
	@RequestMapping("/loginPage")
	public String loginPage() throws Exception{
		return "login";
	}

}
最近下载更多
曾显示  LV6 2024年7月7日
郭宇航裹裹  LV5 2024年6月9日
sunlea  LV20 2024年5月12日
杨豫川  LV12 2024年1月15日
微信网友_6680567232876544  LV8 2023年10月10日
gecongkai  LV8 2023年6月23日
teamdragon  LV6 2023年5月17日
微信网友_6436772032335872  LV3 2023年4月17日
601601lmy  LV5 2023年3月5日
22344341  LV2 2023年1月27日
最近浏览更多
orang801  LV2 2月24日
ryadmin123  LV2 2月14日
微信网友_7310057461567488 2024年12月24日
暂无贡献等级
马平川 2024年12月15日
暂无贡献等级
微信网友_7261870476267520 2024年11月20日
暂无贡献等级
Xppasdf  LV3 2024年10月29日
gql0720  LV1 2024年9月25日
799743530  LV11 2024年7月8日
曾显示  LV6 2024年7月7日
桸桸桸桸桸桸 2024年6月17日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友