Skip to content

Add support for 404, 204, and 3xx responses to the MVC config [SPR-11543] #16168

@spring-projects-issues

Description

@spring-projects-issues

cemo koc opened SPR-11543 and commented

#16166 encouraged me to open this issue :)

Currently one can easily register views to Controllers by WebMvcConfigurer as this:

/**
 * Add view controllers to create a direct mapping between a URL path and
 * view name without the need for a controller in between.
 */
void addViewControllers(ViewControllerRegistry registry);

What I would like to see is easy ways to provide mapping between common http status's such as 404, 301, 302 and 204. It would be great to have redirections, not founds and no contents controllers without the need for a controller by new registry types.

void addRedirectControllers(RedirectControllerRegistry registry);
void addNoContentControllers(NoContentControllerRegistry registry);
void addNotFoundControllers(NotFoundControllerRegistry registry);

This will greatly reduce unnecessary repeated codes.


Affects: 3.2.8, 4.0.2

Referenced from: commits 1ad22b9, 0bbb770, 0e2c5ee

0 votes, 5 watchers

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