SpringMVC:常用关键字
跳到导航
跳到搜索
关键字 | 说明 | 备注 | 链接 | |
---|---|---|---|---|
url映射 | @RequestMapping
|
url映射 | @RequestMapping(value="/editItems",method={RequestMethod.POST,RequestMethod.GET})
|
⇨ |
@PathVaraible
|
动态URI、RESTful | @RequestMapping(value = "/fetch/{id:[a-z]+}/{name} ", method = RequestMethod.GET)
public String getDynamicUriValueRegex(@PathVariable("name") String name) {}
|
⇨ | |
@GetMapping
|
RequestMapping的组合注解 | =@RequestMapping(method =RequestMethod.GET)
|
⇨ | |
参数绑定 | @RequestParam
|
绑定request参数到方法形参 | public String editItems(@RequestParam(value="id",required=true,defaultValue="10001") Integer items_id)throws Exception {}
|
⇨ |
Validation | @Validated
|
public String editItemsSubmit(Integer id,@Validated(value = { ValidGroup1.class}) ItemsCustom itemsCustom,BindingResult bindingResult) throws Exception{}
|
⇨ | |
@NotNull 等
|
校验规则 | @NotNull(message="{item.price.isNull}",groups= {ValidGroup1.class})
|
⇨ | |
数据回显 | Model
|
数据回显(简单类型、pojo回显) |
|
⇨ |
@ModelAttribute
|
pojo类型回显、方法返回值回显 |
|
⇨ | |
json数据交互 | @RequestBody
|
将请求的json串转成pojo对象,进行参数绑定。 | @RequestMapping("/editItemSubmit_RequestJson")
public @ResponseBody Items editItemSubmit_RequestJson(@RequestBody Items items) throws Exception {}
|
⇨ |
@ResponseBody
|
将pojo对象转成json,进行输出。 |