校园商铺-9前端展示系统-10商品详情页的开发

1.后端

1.1 controller层

package com.csj2018.o2o.web.frontend;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.csj2018.o2o.entity.Product;
import com.csj2018.o2o.service.ProductService;
import com.csj2018.o2o.util.HttpServletRequestUtil;

@Controller
@RequestMapping(value="/frontend")
public class ProductDetailController {
	@Autowired
	private ProductService productService;
	
	@RequestMapping(value="/listproductdetailpageinfo",method=RequestMethod.GET)
	@ResponseBody
	private Map<String,Object> showProductDetail(HttpServletRequest request){
		Map<String,Object> modelMap = new HashMap<String,Object>();
		//获取前台传过来的productId
		long productId = HttpServletRequestUtil.getLong(request, "productId");
		Product product = null;
		if(productId != -1) {
			product = productService.getProductById(productId);
			modelMap.put("product", product);
			modelMap.put("success", true);
		}else{
			modelMap.put("success", false);
			modelMap.put("errMsg", "empty productId");
		}
		return modelMap;
	}
}

1.2验证

2.前端

2.1 html

2.2js

2.3验证

posted on 2020-04-03 18:37  singleSpace  阅读(271)  评论(0编辑  收藏  举报