springmvc接收参数遇到的问题

it2022-05-05  99

springmvc   

@RequestParm(value = "hi",required = false) int  hi,

当没有传递参数时,springmvc 初始化 将不能初始化hi为null,就进不去后端controller中的方法。解决办法,可以改成@RequestParm(value = "hi",required = false,defaultValue  = "0") int  hi, 或者改成

@RequestParm(value = "hi",required = false) Integer  hi

 


最新回复(0)