有沒有辦法爲我的spring portlet提供一個默認狀態,如果發生不可用的表示,那麼這個狀態會被解析?Spring Portlet MVC - 如何捕捉映射異常
我收到此異常
10:24:53,187 ERROR [517: org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl] The portlet threw an exception
javax.portlet.UnavailableException: No matching handler method found for portlet request: mode 'view', phase 'ACTION_PHASE', parameters map[[empty]]
at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter$PortletHandlerMethodResolver.resolveHandlerMethod(AnnotationMethodHandlerAdapter.java:488)
at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:354)
at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.doHandle(AnnotationMethodHandlerAdapter.java:345)
at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.handleAction(AnnotationMethodHandlerAdapter.java:280)
at org.springframework.web.portlet.DispatcherPortlet.doActionService(DispatcherPortlet.java:646)
at org.springframework.web.portlet.FrameworkPortlet.processRequest(FrameworkPortlet.java:519)
at org.springframework.web.portlet.FrameworkPortlet.processAction(FrameworkPortlet.java:460)
我想抓住這個異常,並簡單地返回默認的「VIEW」狀態什麼的。
* -portlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:annotation-config/>
<!-- Controllers -->
<bean id="portletController" class="de.nv.spring.portlets.PortletController"/>
<!-- Handler Mappings -->
<bean class="org.springframework.web.portlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
</beans>
我今天在這個特定的項目上試過了。作品。謝謝heikkim – onigunn 2011-07-14 19:22:24