@RequestParam in Spring MVC handling optional parameters

后端 未结 3 1905
你的背包
你的背包 2020-12-07 09:08

Is it possible for a Spring controller to handle both kind of requests?

1) http://localhost:8080/submit/id/ID123432?logout=true

2) http:/

3条回答
  •  隐瞒了意图╮
    2020-12-07 09:22

    You need to give required = false for name and password request parameters as well. That's because, when you provide just the logout parameter, it actually expects for name and password as well as they are still mandatory.

    It worked when you just gave name and password because logout wasn't a mandatory parameter thanks to required = false already given for logout.

提交回复
热议问题