gpt4 book ai didi

java - Spring Portlet MVC - 如何捕获映射异常

转载 作者:行者123 更新时间:2023-12-01 16:02:15 25 4
gpt4 key购买 nike

有没有办法为我的 Spring Portlet 提供默认状态,如果发生不可用的异常,该状态会得到解决?

我收到此异常

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>

最佳答案

您有默认的渲染/操作方法吗?对我来说,以下默认渲染方法有效:

@RenderMapping(params="!render")
public String defaultRender(RenderRequest req, RenderResponse res, Model model) throws PortalException, SystemException {
// do something
}

注释值!render表示如果不存在渲染参数则运行此函数。直观上,您可以对操作参数使用相同的方法。

关于java - Spring Portlet MVC - 如何捕获映射异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3545838/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com