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:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user