Restful
1 restful风格化,url上的参数通过{}点符绑定,RequestMapping("item/{id}")
2 点位符参数名与方法参数名不一致时,通过@PathVariable绑定
//restful风格 @RequestMapping("item/{id}") public String itemQuery(@PathVariable("id") Integer ids , Model model){ Item item = itemService.getItemById(ids); model.addAttribute("item", item); return "itemEdit"; }
3 在web.xml上修改urlpattern为/ ,访问url
 

注:@PathVariable与@RequestParam的区别:
@PathVariable映射的是RequestMapping设置的,url地址的参数 @RequestMapping("item/{id}")
@RequestParam绑定的是请求的参数,通过?设置,比如 localhost:8080/item/3?id=xxx

                
            
        
浙公网安备 33010602011771号