java path 注解_@PathVariable注解的使用和@Requestparam
一、?@PathVariable
@PathVariable這是一個路徑映射格式的書寫方式注解,在類映射路徑的后加上/{對應方法參數中屬性@PathVariable("code")中的code},
@SuppressWarnings({ "unchecked", "rawtypes" })
@RequestMapping(value = "/decodeUserInfo/{codee}", method = RequestMethod.GET)
@ResponseBody
public Map decodeUserInfo(@PathVariable("codee") String codee) {
Map map = new HashMap();
/自己定義的code
String code = codee;
二、@Requestparam注解將請求參數綁定至方法參數即你可以使用@RequestParam注解將請求參數綁定到你控制器的方法參數上
1.value:請求參數名(必須配置)
2.required:是否必須,默認true,即請求中必須包含該參數,如果沒有包含,將會拋出異常(可選配置)
3.defaultValue:默認值,如果設置了該值,require將自動設為false,無論你是否配置了required,配置了什么值,required將自動設為false
@Requestparam(value="表示參數名字",require=boolean類型表示是否為必須,defaultValue=“表示默認值”)
@SuppressWarnings({ "unchecked", "rawtypes" })
@RequestMapping(value = "/decodeUserInfo", method = RequestMethod.GET)
@ResponseBody
public Map decodeUserInfo(@RequestParam String codee) {
Map map = new HashMap();
/自己定義的code
String code = codee;
總結
以上是生活随笔為你收集整理的java path 注解_@PathVariable注解的使用和@Requestparam的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 如何去掉电脑桌面图标的小黄锁电脑如何取消
- 下一篇: java this用法_java中thi