Polish standard Spring MVC exception handling

Rename ExceptionHandlerSupport to ResponseEntityExceptionHandler and
emphasize the contrast to DefaultHandlerExceptionResovler -- i.e.
one returns a ResponseEntity and relies on message converters while
the other returns a ModelAndView and relies on view resolution.

Issue: SPR-9290
This commit is contained in:
Rossen Stoyanchev
2012-08-27 14:06:06 -04:00
parent 0a6b1167a7
commit da05b094f5
7 changed files with 157 additions and 129 deletions

View File

@@ -17,8 +17,13 @@
package org.springframework.web;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import javax.servlet.ServletException;
import org.springframework.http.HttpMethod;
/**
* Exception thrown when a request handler does not support a
* specific request method.
@@ -95,4 +100,15 @@ public class HttpRequestMethodNotSupportedException extends ServletException {
return this.supportedMethods;
}
/**
* Return the actually supported HTTP methods, if known, as {@link HttpMethod} instances.
*/
public Set<HttpMethod> getSupportedHttpMethods() {
Set<HttpMethod> supportedMethods = new HashSet<HttpMethod>();
for (String value : this.supportedMethods) {
supportedMethods.add(HttpMethod.valueOf(value));
}
return supportedMethods;
}
}

View File

@@ -32,7 +32,7 @@ import org.springframework.stereotype.Component;
*
* <p>It is typically used to define {@link ExceptionHandler @ExceptionHandler},
* {@link InitBinder @InitBinder}, and {@link ModelAttribute @ModelAttribute}
* methods that apply across controller class hierarchies.
* methods that apply to all {@link RequestMapping @RequestMapping} methods.
*
* @author Rossen Stoyanchev
* @since 3.2