- 项目结构:
controller:
//查询商品信息,返回json
@RequestMapping(value = "/findProductJson")
@ResponseBody
public List<Product> findProductJson(Map map){
List<Product> productList=productService.findAll();
map.put("productList",productList);
return productList;
}
//新增商品信息,重定向到product.save,返回json
@RequestMapping(value = "/saveProduct",method = RequestMethod.POST)
public String saveProduct(Product p){
productService.save(p);
return "redirect:/index/findProduct";
}