Spring MVC: how to indicate whether a path variable is required or not? -


i doing spring web. controller method, able use requestparam indicate whether parameter required or not. example:

@requestmapping({"customer"})  public string surveys(httpservletrequest request,  @requestparam(value="id", required = false) long id,             map<string, object> map) 

i use pathvariable such following:

@requestmapping({"customer/{id}"})  public string surveys(httpservletrequest request,  @pathvariable("id") long id,             map<string, object> map)  

how can indicate whether path variable required or not? need make optional because when creating new object, there no associated id available until saved.

thanks help!

there's no way make optional, can create 2 methods 1 having @requestmapping({"customer"}) annotation , other having @requestmapping({"customer/{id}"}) , act accordingly in each.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -