@RequestMapping

1.窄化请求,在controller类前加@RequestMapping注解

@Controller
@RequestMapping("/items")
public class ItemsController {}```


2.value指定url路径映射,method指定请求方法

//商品信息修改页面
@RequestMapping(value="/editItems",method={RequestMethod.POST,RequestMethod.GET})
public ModelAndView editItems() throws Exception{
ItemsCustom itemsCustom = itemsService.findItemsById(1);

ModelAndView modelAndView = new ModelAndView();

modelAndView.addObject("itemsCustom", itemsCustom);

modelAndView.setViewName("items/editItems");

    return modelAndView;

}```

你可能感兴趣的:(@RequestMapping)