java Spring Interceptor隐藏Liferay错误消息

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java Spring Interceptor隐藏Liferay错误消息相关的知识,希望对你有一定的参考价值。

	<bean id="hideDefaultLiferaySessionErrorMessageInterceptor" class="it.intesys.arag.interceptor.HideDefaultLiferaySessionErrorMessageInterceptor" />

	<bean class="org.springframework.web.portlet.mvc.annotation.DefaultAnnotationHandlerMapping">
	    <property name="interceptors">
	        <list>
	            <ref bean="hideDefaultLiferaySessionErrorMessageInterceptor" />
	        </list>
	    </property>
	</bean>
package it.intesys.arag.interceptor;

import javax.portlet.PortletConfig;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;

import org.springframework.web.portlet.handler.HandlerInterceptorAdapter;

import com.liferay.portal.kernel.portlet.LiferayPortletConfig;
import com.liferay.portal.kernel.servlet.SessionMessages;
import com.liferay.portal.kernel.util.JavaConstants;

public class HideDefaultLiferaySessionErrorMessageInterceptor extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandleRender(RenderRequest request, RenderResponse response, Object handler)
        throws Exception {

        PortletConfig pcc = (PortletConfig) request.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
        SessionMessages.add(request, ((LiferayPortletConfig) pcc).getPortletId() + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);

        return super.preHandleRender(request, response, handler);
    }

}

以上是关于java Spring Interceptor隐藏Liferay错误消息的主要内容,如果未能解决你的问题,请参考以下文章

spring中过滤器(filter)、拦截器(interceptor)和切面(aop)的执行顺序

spring security 默认拦截和 springmvc 的Interceptor 拦截冲突的问题

Spring Interceptor 不生效

Spring Boot 9:Interceptor

Spring MVC Interceptor

spring filter and interceptor