Skip to content

Add (Request)ParameterHandlerMapping class to Spring MVC [SPR-2309] #6998

@spring-projects-issues

Description

@spring-projects-issues

Glen Mazza opened SPR-2309 and commented

I have found the RequestParameterHandlerMapping class, defined on p. 92-93 of APress' Expert Spring MVC and Web Flow book, to be very useful for my work. I'm inclined to recommend adding a class like this one to the Spring 2.0 Core. (Spring already has a very similar ParameterHandlerMapping[1] in 2.0, but that is only for portlets, not Spring MVC.)

Here is my use case for it: I have a report generation system that uses a "report" parameter to determine which report to generate:
https://www.mycompany.com/ReportGen/login?report=ReportA
https://www.mycompany.com/ReportGen/login?report=ReportB
https://www.mycompany.com/ReportGen/login?report=ReportC
...

Previously, I mapped the "login" URL via SimpleURLHandlerMapping to a (SimpleFormController subclass) loginController, which internally did hardcoded validation to make sure that the report parameter was valid (e.g., raise an exception if report=doesntexist, but for valid report param values redirect after login to a report-specific controller to collect the report's filtering criteria.) This however, required me to keep modifying my loginController class everytime a report was added or removed.

But by using RequestParameterHandlerMapping I can now map the parameters ReportA, ReportB, ReportC, etc., individually to loginController in my web config file. With this design, report=doesntexist will never activate loginController to begin with so I can just return an error page in that case. It seems like a cleaner design.

Thanks,
Glen

[1] http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/web/portlet/handler/ParameterHandlerMapping.html


Affects: 2.0 RC3

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