Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Case insensitve matching of Query parameters using ModelAttribute [SPR-13676] #18251

Closed
spring-projects-issues opened this issue Nov 12, 2015 · 4 comments
Assignees
Labels
in: web status: declined type: enhancement

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Nov 12, 2015

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

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Nov 17, 2015

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?

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Nov 25, 2015

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.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Nov 30, 2015

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.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jan 13, 2016

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.

@spring-projects-issues spring-projects-issues added status: declined type: enhancement in: web labels Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web status: declined type: enhancement
Projects
None yet
Development

No branches or pull requests

2 participants