📄 securityinterceptor.java
字号:
package com.kelefa.sms.interceptor;
import com.opensymphony.xwork.Action;
import com.opensymphony.xwork.ActionInvocation;
import com.opensymphony.xwork.ActionSupport;
import com.opensymphony.xwork.interceptor.Interceptor;
public class SecurityInterceptor
implements Interceptor
{
public SecurityInterceptor()
{
}
public void destroy()
{
}
public void init()
{
}
public String intercept( ActionInvocation invocation )
throws Exception
{
if ( !isAuthorized( invocation ) ) {
return Action.LOGIN;
}
return invocation.invoke();
}
protected boolean isAuthorized( ActionInvocation actionInvocation )
{
boolean logined = "true".equals( actionInvocation
.getInvocationContext()
.getSession()
.get( "login" ) );
if ( !logined ) {
ActionSupport action = ( ActionSupport ) actionInvocation.getAction();
action.addActionError( "请你先登陆" );
return false;
}
return true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -