Send Boolean as a controller path

Is it possible and good practice to send Boolean as pathvariable for the controller in url? I am using spring 3.1 and trying to send boolean from Jsp to the controller as @Pathvariable ("yesorNo") boolean yesOrNo. But keep getting the error as the request is syntactically incorrect. Any insight?

+5
source share
1 answer

Yes you can, it would look like

@RequestMapping(value="value/{someVal}")
public void handleBooleanParameter(@PathVariable("someVal")boolean someVal){
   //do something
}

Then you will access it with

http://<base url>/value/true

or

http://<base url>/value/false
+3
source

All Articles