@PathVariable與@RequestBody的區別,及前段請求接口的寫法。


@PathVariable

  1:接受參數時,地址欄為:/{args1}/{args2}

  2:用法:(@PathVariable(value = "args")Long  id)

  3:GET請求方法

@RequestParams

  1:接受參數時,地址欄為:/args=?

  2:用法:(@PathVariable("args")Long  id)

  3:GET請求方法

@RequestBody
  1:接受參數時,地址欄為:/args1=?&args2=?

  2:用法:(@RequestBody(value = "args")Long  id)

  3:POST請求方式

@GetMapping("/methodPath"):指明了get請求 

@PostMapping("/methodPath"):指明了post請求

@RequestMapping(value = "/methodPath" , method = RequestMethod.POST)

@RequestMapping(value = "/methodPath" , method = RequestMethod.GET)

post請求:

export const methodsName = (request) => {

  return axios.request({

    url:‘請求路徑’,

    data:request,

    method:"post"

  })

}

get請求:

exportconst methodsNamr =(args1,args2)= {

  return axios.request({

    url:”/abc?x1=”+ args1 + “&x2=“+args2,

    method:‘get’

  })

}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM