spring - Same endpoint, with and without @RequestParam -


in spring boot possible have same endpoint , without @requestparam

a this:

@getmapping(value = "/billing-codes") public responseentity getbillingcodes(         @authenticationprincipal user loggedinuser,         @requestparam(name = "billingcodeid") string billingcodeid,         @requestparam(name = "direction") string direction,         @requestparam(name = "limit") string limit) { 

b this:

@getmapping(value = "/billing-codes") public responseentity getbillingcodes(         @authenticationprincipal user loggedinuser) { 

the requests different

a request

/billing-codes?billingcodeid=&direction=&limit 

b request

/billing-codes 

it possible test if names of request parameters part of request? testing if request parameters null or empty won't work since have case , should still processed in a.

no, can have 1 method couple of url , http method in same controller. you'll need use 1 method required = false :

public responseentity getbillingcodes(         @authenticationprincipal user loggedinuser,         @requestparam(name = "billingcodeid", required = false) string billingcodeid,         @requestparam(name = "direction"m required = false) string direction,         @requestparam(name = "limit", required = false) string limit) {} 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -