Closed
Description
Nick Padgett opened SPR-5953 and commented
It would be nice if SimpleMappingExceptionResolver had the ability to resolve HTTP status codes as well. Currently, I have the following class:
public class StatusCodeMappingExceptionResolver extends
SimpleMappingExceptionResolver {
private Map<String, Integer> statusCodeMappings;
@Override
protected Integer determineStatusCode(final HttpServletRequest request,
final String viewName) {
Integer statusCode = null;
// Check for specific status code mappings.
if (null != this.statusCodeMappings) {
statusCode = this.statusCodeMappings.get(viewName);
}
// Return default status code else, if defined.
if (null == statusCode) {
statusCode = super.determineStatusCode(request, viewName);
}
return statusCode;
}
public void setStatusCodeMappings(Map<String, Integer> statusCodeMappings) {
this.statusCodeMappings = statusCodeMappings;
}
}
Referenced from: commits 12e43ff
1 votes, 2 watchers