java中 queryparam_java – 何时使用@QueryParam和@PathParam
我不是問這里已經(jīng)問過的問題:
What is the difference between @PathParam and @QueryParam
這是一個“最佳實踐”或常規(guī)問題。
什么時候使用@PathParam和@QueryParam。
我可以想到的是,決定可能使用兩者來區(qū)分信息模式。讓我在下面說明我的LTPO – 不完美的觀察。
PathParam使用可以保留用于信息類別,這將很好地落入信息樹的分支。 PathParam可以用于向下鉆取到實體類層次結(jié)構(gòu)。
而QueryParam可以保留用于指定屬性以定位類的實例。
例如,
> / Vehicle / Car?registration = 123
> / House / Colonial?region = newengland
/ category?instance
@GET
@Path("/employee/{dept}")
Patient getEmployee(@PathParam("dept")Long dept, @QueryParam("id")Long id) ;
vs / category / instance
@GET
@Path("/employee/{dept}/{id}")
Patient getEmployee(@PathParam("dept")Long dept, @PathParam("id")Long id) ;
vs?category實例
@GET
@Path("/employee")
Patient getEmployee(@QueryParam("dept")Long dept, @QueryParam("id")Long id) ;
我不認(rèn)為有一個標(biāo)準(zhǔn)的做法。在那兒?但是,我想聽聽人們?nèi)绾问褂肞athParam和QueryParam來區(qū)分他們的信息,如上面例舉的。我也很愿意聽到這種做法背后的原因。
總結(jié)
以上是生活随笔為你收集整理的java中 queryparam_java – 何时使用@QueryParam和@PathParam的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 什么是pay类交易
- 下一篇: 公积金贷款有哪些要求