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

Allow SimpleMappingExceptionResolver to Resolve HTTP Status Codes [SPR-5953] #10621

Closed
spring-projects-issues opened this issue Jul 23, 2009 · 1 comment
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

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

@spring-projects-issues
Copy link
Collaborator Author

Arjen Poutsma commented

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants