hasroletag.java
来自「这是一个轻便的j2ee的web应用框架,是一个在多个项目中运用的实际框架,采用s」· Java 代码 · 共 53 行
JAVA
53 行
/*
* 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 + =
减小字号Ctrl + -
显示快捷键?