src/com/shop/controller/indexController.java
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
package com.shop.controller;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
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 org.springframework.web.bind.annotation.RequestParam;
import com.shop.po.Category;
import com.shop.po.Product;
import com.shop.service.CategoryService;
import com.shop.service.ProductService;
@Controller
public class indexController {
@Autowired
private CategoryService categoryService;
@Autowired
private ProductService productService;
@RequestMapping("/index")
public String index(Model model,HttpServletRequest request) throws Exception {
//查询一级分类
List<Category> cList = categoryService.findCategory();
request.getSession().getServletContext().setAttribute("cList",cList);
// model.addAttribute("cList", cList);
//查询热门商品
List<Product> hList= productService.findHotProduct();
model.addAttribute("hList", hList);
//查询最新商品
List<Product> nList = productService.findNewProduct();
model.addAttribute("nList", nList);
//滚动图片专用,最多显示3个商品
List<Product> sList;
if(hList.size()>3)
{
sList = new ArrayList<Product>();
sList.add(hList.get(0));
sList.add(hList.get(1));
sList.add(hList.get(2));
model.addAttribute("sList", sList);
}
else
{
model.addAttribute("sList", hList);
}
return "index";
}
@RequestMapping("/about")
public String about(Model model,HttpServletRequest request) throws Exception {
return "about";
后面还有 44 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。
