📄 hasroletag.java
字号:
/*
* Created on 2004-4-1
*
*/
package com.esimple.service.rbac.view.taglib;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
import com.esimple.service.rbac.*;
import com.esimple.framework.util.StringUtils;
/**
*
* @author steven
*
*/
public class HasRoleTag extends BodyTagSupport{
private String roles = null;
public String getRoles() {
return (this.roles);
}
public void setRoles(String roles) {
this.roles = roles;
}
public int doStartTag() throws JspException {
Object obj = pageContext.getSession().getAttribute(User.SESSION_KEY);
if( obj == null )return (SKIP_BODY);
User user = (User)obj;
String[] roleArray = StringUtils.split(roles,",",true,true);
if(roleArray.length >0){
for(int i=0;i<roleArray.length;i++){
if( user.hasRole( roleArray[i] ) ){
return (EVAL_BODY_TAG);
}
}
}else{
return (SKIP_BODY);
}
return (SKIP_BODY);
}
public void release() {
super.release();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -