⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hasroletag.java

📁 这是一个轻便的j2ee的web应用框架,是一个在多个项目中运用的实际框架,采用struts,hebinate,xml等技术,有丰富的tag,role,navigation,session,dictio
💻 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 + -