Skip to content

ability to set response status on ModelAndView [SPR-13560] #18136

@spring-projects-issues

Description

@spring-projects-issues

Christopher Smith opened SPR-13560 and commented

I am supporting resource deletion under certain circumstances, but semantic preconditions (referential integrity) must be enforced, and if they aren't, I want to return a 422. This is fairly simple in a REST controller, but in an HTML controller, I want to send the user an HTML page describing the condition, along with the 422 status code.

I can programmatically set the status code for a REST response with a ResponseEntity, and I can statically set the status code for an HTML response with @ResponseStatus, but there's no mechanism for programmatically setting the status code when using a ModelAndView. I would like a status field on ModelAndView that I can set based on controller logic.


Affects: 4.2.1

Issue Links:

1 votes, 4 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