Manikandan Nagarajan opened SPR-13676 and commented

I wanted to make my URL Case Insensitive, including the query string parameters. I currently use ModelAttribute to bind request params to my model.

I have googled about this a lot in the past couple of days and the only viable solution that I could find was to use a Custom Filter and use RequestParams to bind the values. Here is the best I could find so far, http://stackoverflow.com/a/29533456/3131696 but this doesn't support case insensitive matching.

As the Web API is built on top of HTTP, I would like to confirm to the URL standards and make my query parameters case insensitive.

Can this be made available ?

Note: There was another similar request #17876, but the fix only work for Path parameters, this request is to extend that to Query parameters as well.


Affects: 4.2.3

Reference URL: http://stackoverflow.com/questions/32364126/spring-mvc-case-insensitive-get-parameters-mapping

4 votes, 5 watchers

Comment From: spring-projects-issues

Rossen Stoyanchev commented

Consider what binding the request to a target object means: for each request parameter check through reflection if the target object has a matching property. There is no easy way to do this in a case insensitive manner through the PropertyAccessor we use internally.

You might have to create an object for accepting web input with lowercase field names, as suggested in the SO thread. Then you can predictably turn query params to lower-case. I'm wondering is this really worth it? Is case insensitive that important for query parameters, is anyone typing them in, or are they sent by programatic clients?

Comment From: spring-projects-issues

Manikandan Nagarajan commented

Hi Rossen Stoyanchev,

In a normal case no one would be typing this in, but there are cases where someone might use this on rare occasions.

Also this makes my API URL case sensitive, you can call me paranoid, but I just don't like it that way and I am sure that many people would have felt the same way.

I have talked with people who got stuck here and just sorted to not use @ModelAttribute at all and moved over to using @RequestParam.

Comment From: spring-projects-issues

Rossen Stoyanchev commented

Why is it such a great concern though especially for the rare occasion? What's wrong with a 400 error that explains what parameter is missing or is misspelled? Sure we could spend some effort to make that possible but I just don't see a strong motivation for it.

If you really want it, you could even today, create a command object with lowercase field names combined with a Filter that decorates the request and returns lowercase request parameter names (as suggested in the SO thread). Or perhaps using "_" to separate multi-word query parameters combined with a Filter that turns those to camelback notation.

Comment From: spring-projects-issues

Manikandan Nagarajan commented

Yes, that might be possible but it looks more like a work around to me than an actual solution. I was hoping for something more out of the box.

I don't have a compelling case for this as well, so if this is more trouble than its worth feel free to drop this.

Comment From: ledents

If you don't think it is a big deal, just consider browser history caches on services with optional parameters, once you got a result ignoring the mis-typed parameter, you'll have to clear the history cache as some(or most) browser will rewrite the parameter to the mis-typed one if the rest of the url matches !! This is a very big deal for most users even for me that understand what is happening and why that is. Clearing the history cache is not something I like to do often and typing mistakes do happen !