Blogger Information
Blog 110
fans 0
comment 0
visits 112337
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
SpringMVC的默认参数类型的举例
Coco
Original
582 people have browsed it

  @RequestMapping("/itemEdit")

  public String queryItemById(HttpServletRequest request, ModelMap model) {

  // 从request中获取请求参数

  String strId=request.getParameter("id");

  Integer id=Integer.valueOf(strId);

  // 根据id查询商品数据

  Item item=this.itemService.queryItemById(id);

  // 把结果传递给页面

  // ModelAndView modelAndView=new ModelAndView();

  // 把商品数据放在模型中

  // modelAndView.addObject("item", item);

  // 设置逻辑视图

  // modelAndView.setViewName("itemEdit");

  // 把商品数据放在模型中

  model.addAttribute("item", item);

  return "itemEdit";

  }

  //去修改页面 入参 id

  @RequestMapping(value="/itemEdit.action")

  public ModelAndView toEdit(

  HttpServletRequest request,HttpServletResponse response

  ,HttpSession session,Model model){

  String id=request.getParameter("id");

  tems items=itemService.selectItemsById(Integer.parseInt(id));

  ModelAndView mav=new ModelAndView();

  mav.addObject("item", items);

  mav.setViewName("editItem");

  return mav;

  }

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post