Is it possible to have empty RequestParam values use the defaultValue?

后端 未结 5 1882
北海茫月
北海茫月 2020-11-30 20:15

if I have a a request mapping similar to the following:

@RequestMapping(value = \"/test\", method = RequestMethod.POST)
@ResponseBody
public void test(@Reque         


        
5条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-30 21:03

    You can also do something like this -

     @RequestParam(value= "i", defaultValue = "20") Optional i
    

提交回复
热议问题