RequestParam can't properly parse an optional boolean parameter [SPR-5410] #10083
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: enhancement
A general enhancement
Milestone
Scott Battaglia opened SPR-5410 and commented
I'm using the Spring MVC's annotation-based support and specified a method signature as follows:
public void validateCas10Request(
@RequestParam
(value="renew",required=false) final boolean renew,@RequestParam
(value="service",required=true) final String service,@RequestParam
(value="ticket",required=true) final String ticket, final Writer writer) {If I do not have a renew request parameter the following error is thrown:
java.lang.IllegalStateException: Optional boolean parameter 'renew' is not present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type.
Is there a reason that a null parameter is not converted to false, as per the JavaDoc's parseBoolean method for Boolean?
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Boolean.html#parseBoolean(java.lang.String)
Affects: 2.5.6
The text was updated successfully, but these errors were encountered: