1. 项目结构:
2. 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";
}
3. html页面(easyui)
新增、查询
<head>
<link rel="stylesheet" type="text/css" href="../static/easyui/themes/default/easyui.css" th:href="@{/easyui/themes/default/easyui.css}"/>
<link rel="stylesheet" type="text/css" href="../static/easyui/themes/icon.css" th:href="@{/easyui/themes/icon.css}"/>
<link rel="stylesheet" type="text/css" href="../static/easyui/themes/color.css" th:href="@{/easyui/themes/color.css}"/>
<link rel="stylesheet" type="text/css" href="../static/easyui/demo/demo.css" th:href="@{/easyui/demo/demo.css}"/>
<script type="text/javascript" src="../static/easyui/jquery.min.js"