報錯信息:
Caused by: java.lang.IllegalStateException: PathVariable annotation was empty on param 0.
未修改之前的代碼:
@PostMapping("/findPageByCondition/{currentPage}/{pageSize}")
public PageResult<SgwServerConf> findPageByCondition(@RequestBody SgwServerConfQueryCondition queryCondition, @PathVariable int currentPage, @PathVariable int pageSize);
修改之后:
@PostMapping("/findPageByCondition/{currentPage}/{pageSize}")
public PageResult<SgwServerConf> findPageByCondition(@RequestBody SgwServerConfQueryCondition queryCondition, @PathVariable(value = "currentPage") int currentPage, @PathVariable(value = "pageSize") int pageSize);
這個問題可能是idea編輯器的版本問題導(dǎo)致的,我用的idea是2019.2版本的,同事用的2017版本的,同樣的代碼,在我的工程里不報錯,可以正常運行,打成jar包可以部署到服務(wù)器上也沒問題,jar包用同事的windows運行也沒問題,但是一用同事的idea運行就報上邊的錯誤信息了,必須加上@PathVariable 注解value屬性值才不報錯。
本文摘自 :https://blog.51cto.com/u