Created
June 4, 2013 08:32
-
-
Save relax-more/5704492 to your computer and use it in GitHub Desktop.
[java][spring] @ExceptionHandler が利用できなくてハマったので調査した
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AnnotationMethodHandlerExceptionResolverの追加が必要。 | |
今回の自分のケースでは、SimpleMappingExceptionResolverを既に利用していたので、 ExceptionResolver の優先順位付けをして、 | |
AnnotationMethodHandlerExceptionResolver を優先度高く設定する必要があった。 | |
詳しくは下記 | |
http://forum.springsource.org/showthread.php?102713-Spring-Web-MVC-ExceptionHandler-ignore-when-exceptionResolver-in-place&p=347448#post347448 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver" p:defaultErrorView="uncaughtException"> | |
<property name="exceptionMappings"> | |
<props> | |
<prop key=".DataAccessException">dataAccessFailure</prop> | |
<prop key=".NoSuchRequestHandlingMethodException">resourceNotFound</prop> | |
<prop key=".TypeMismatchException">resourceNotFound</prop> | |
<prop key=".MissingServletRequestParameterException">resourceNotFound</prop> | |
</props> | |
</property> | |
</bean> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- important p:order="1" and p:order="2"--> | |
<!-- and AnnotationMethodHandlerExceptionResolver --> | |
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerExceptionResolver" p:order="1" /> | |
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver" p:order="2" p:defaultErrorView="uncaughtException"> | |
<property name="exceptionMappings"> | |
<props> | |
<prop key=".DataAccessException">dataAccessFailure</prop> | |
<prop key=".NoSuchRequestHandlingMethodException">resourceNotFound</prop> | |
<prop key=".TypeMismatchException">resourceNotFound</prop> | |
<prop key=".MissingServletRequestParameterException">resourceNotFound</prop> | |
</props> | |
</property> | |
</bean> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment