有没有办法为我的spring portlet提供一个默认状态,如果发生不可用的expcetion就会解析它?
我接受了这个例外
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>
答案 0 :(得分:1)
你有默认的渲染/动作 - 方法吗?对我来说,以下默认渲染方法有效:
@RenderMapping(params="!render")
public String defaultRender(RenderRequest req, RenderResponse res, Model model) throws PortalException, SystemException {
// do something
}
注释值!render 表示如果不存在render-parameter则会运行此操作。直觉上,您可以在action-parameter上使用相同的方法。
答案 1 :(得分:0)