Я использую Spring 3, и я попытался добавить сопоставление исключений следующим образом:
<bean
class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<map>
<entry key="it.jsoftware.jacciseweb.controllers.AcciseAuthException" value="/jsp/errorUserPage.jsp" />
</map>
</property>
</bean>
Конечно, JSP не находятся в WEB-INF, но находятся в корневой папке с именем jsp
,То, что я получаю, это моя пользовательская страница для обработки 404, которую я настроил в web.xml.Что не так?
Вот журнал Spring с поддержкой DEBUG:
[08 mar 2011 15:20:11,451 CET] [DEBUG] [HandlerMethodInvoker] [invokeHandlerMethod:173] - Invoking request handler method: public org.springframework.web.servlet.ModelAndView it.jsoftware.jacciseweb.controllers.MainController.prodottiList(int,java.lang.String,boolean,java.lang.Integer,javax.servlet.http.HttpSession) throws java.lang.Exception
[08 mar 2011 15:20:11,452 CET] [DEBUG] [SimpleMappingExceptionResolver] [resolveException:132] - Resolving exception from handler [it.jsoftware.jacciseweb.controllers.MainController@1876a6d]: it.jsoftware.jacciseweb.controllers.AcciseAuthException
[08 mar 2011 15:20:11,454 CET] [DEBUG] [SimpleMappingExceptionResolver] [findMatchingViewName:202] - Resolving to view '/jsp/errorUserPage.jsp' for exception of type [it.jsoftware.jacciseweb.controllers.AcciseAuthException], based on exception mapping [it.jsoftware.jacciseweb.controllers.AcciseAuthException]
[08 mar 2011 15:20:11,454 CET] [DEBUG] [SimpleMappingExceptionResolver] [getModelAndView:294] - Exposing Exception as model attribute 'exception'
[08 mar 2011 15:20:11,458 CET] [DEBUG] [DispatcherServlet] [processHandlerException:1001] - Handler execution resulted in exception - forwarding to resolved error view: ModelAndView: reference to view with name '/jsp/errorUserPage.jsp'; model is {exception=it.jsoftware.jacciseweb.controllers.AcciseAuthException}
it.jsoftware.jacciseweb.controllers.AcciseAuthException
at it.jsoftware.jacciseweb.controllers.ApplicationUserStatus.checkIfUserPrivilegeBelowOrEqual(ApplicationUserStatus.java:162)
at it.jsoftware.jacciseweb.controllers.MainController.prodottiList(MainController.java:401)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
[08 mar 2011 15:20:11,464 CET] [DEBUG] [DefaultListableBeanFactory] [invokeInitMethods:1461] - Invoking afterPropertiesSet() on bean with name '/jsp/errorUserPage.jsp'
[08 mar 2011 15:20:11,465 CET] [DEBUG] [DefaultListableBeanFactory] [doGetBean:242] - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
[08 mar 2011 15:20:11,465 CET] [DEBUG] [DispatcherServlet] [render:1045] - Rendering view [org.springframework.web.servlet.view.JstlView: name '/jsp/errorUserPage.jsp'; URL [/jsp/errorUserPage.jsp]] in DispatcherServlet with name 'springDispatcher'
[08 mar 2011 15:20:11,466 CET] [DEBUG] [JstlView] [exposeModelAsRequestAttributes:328] - Added model object 'exception' of type [it.jsoftware.jacciseweb.controllers.AcciseAuthException] to request in view with name '/jsp/errorUserPage.jsp'
[08 mar 2011 15:20:11,466 CET] [DEBUG] [JstlView] [renderMergedOutputModel:236] - Forwarding to resource [/jsp/errorUserPage.jsp] in InternalResourceView '/jsp/errorUserPage.jsp'
[08 mar 2011 15:20:11,467 CET] [DEBUG] [OpenSessionInViewInterceptor] [afterCompletion:212] - Closing single Hibernate Session in OpenSessionInViewInterceptor
[08 mar 2011 15:20:11,468 CET] [DEBUG] [SessionFactoryUtils] [closeSession:789] - Closing Hibernate Session
[08 mar 2011 15:20:11,468 CET] [DEBUG] [DispatcherServlet] [processRequest:674] - Successfully completed request
ОБНОВЛЕНИЕ
Я добавляю это для кого 'Увидим этот вопрос в будущем.Эта конфигурация в порядке, JSP был просто не прав.В любом случае, спасибо за ответ, который предлагает лучший способ справиться с этим - Spring 3.