Skip to content

RequestParam can't properly parse an optional boolean parameter [SPR-5410] #10083

@spring-projects-issues

Description

@spring-projects-issues

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

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions