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

Support combining class-level @RequestMappings by inheritance [SPR-16746] #21287

spring-projects-issues opened this issue Apr 19, 2018 · 1 comment
in: web status: declined type: enhancement


Copy link

@spring-projects-issues spring-projects-issues commented Apr 19, 2018

Grzegorz Pijański opened SPR-16746 and commented

Let's say that we have ProductController.
It's reasonable to annotate it with class-level @RequestMapping("/product") in order to group all methods under same mapping.
But what if some endpoints need to have "/admin" prefix?

Right now this is not possible.

Putting @RequestMapping("/product") or @RequestMapping("/admin/product") on every method in this controller is tedious and having separate ProductController and ProductAdminController is not best solution either.

It would be great if SpringWeb could introduce @Prefix("/admin") annotation, that would prefix class-level @RequestMapping

It would be even nicer when it was possible to support combining class-level @RequestMappings by inheritance.

The example below:

public class AdminController {
@RequestMapping("/product", useSuperclassMapping = true)
public class ProductAdminController extends AdminController {

And instead of "/product", ProductAdminController's method could be called as "/admin/product".

1 votes, 3 watchers

Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Apr 20, 2018

Rossen Stoyanchev commented

When @RequestMapping is used on the method level, what would useSuperclassMapping mean? Such a method already inherits a class-level @RequestMapping, so it can't inherit from a base class method it overrides as one might assume. I'm afraid introducing a new annotation into the mix isn't simplifying things either.

It's a little hard to give more specific advice without knowing what these endpoints do (i.e. product vs admin product) do and how they relate to each other. 

@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
in: web status: declined type: enhancement
None yet

No branches or pull requests

2 participants