Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

app-context.xml中添加:xml中添加一个Ajax交互的拦截器:

Code Block
xml
<bean parent="dorado.viewServiceInterceptorRegister">
    <property name="methodInterceptor">
        <bean class="com.xxx.xxx.system.common.UserSessionViewServiceInterceptor" />
    </property>
</bean>

java代码:java参考代码:

Code Block
java
package com.xxx.xxx.system.common;

import javax.servlet.http.HttpServletRequest;

import org.aopalliance.intercept.MethodInvocation;

import com.bstek.dorado.view.resolver.ClientRunnableException;
import com.bstek.dorado.view.service.AbstractRemoteServiceMethodInterceptor;
import com.bstek.dorado.web.DoradoContext;

public class UserSessionViewServiceInterceptor extends AbstractRemoteServiceMethodInterceptor {

	@Override
	protected Object invoke(MethodInvocation invocation, String serviceName) throws Throwable {
        HttpServletRequest request  = DoradoContext.getCurrent().getRequest();
        Object user = request.getSession().getAttribute("userObject");
        if (null==user){
        	throw new ClientRunnableException("Session超时","window.top.location.href='./index.html';");
        }
        Object object = invocation.proceed();//调用默认的ajax服务
        return object;
	}
}

...