1.springboot集成swagger2時get方式傳參在swagger-ui.html中相應的api中明明爲參數username賦值了。html
可是在發送以後老是提示「Required String parameter‘username’ is not present」。須要說明的是我在 controller的方法裏已經給這個參數註明是不可空的。可是我在swagger裏是傳了參的。說明是swagger這塊配置有問題spring
@ApiOperation(value="Swagger測試1",notes="Swagger測試2")
@ApiImplicitParams({
@ApiImplicitParam(name="username",value="用戶姓名",required=true,dataType="String"),api
@ApiImplicitParam(name="userage",value="用戶年齡",required=true,paramType = "query",dataType="String")//改成!!!!正確寫法
})
@RequestMapping(value = "/hello3", method = RequestMethod.GET)springboot
是在@ApilmplicitParam中少了一個參數 paramType="query" 加在後面就好了。(網上的例子要麼沒寫,要麼都是寫成path了。我估計都是抄的)。restful
這個屬性是指定參數放的位置的。app
paramType:參數放在哪一個地方
header-->請求參數的獲取:@RequestHeader
query-->請求參數的獲取:@RequestParam
path(用於restful接口)-->請求參數的獲取:@PathVariable
body(不經常使用)
form(不經常使用)測試