liuxiaolong
2019-05-09 0d1d88cdb668e75ea8609417ac18ae19947e9525
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.basic.x01.tag;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
 
import com.basic.x01.base.BaseController;
 
/**
 * 权限检查标签 <f:access action="a,b,c" > </f:access>
 * 
 * @company 北京贝思科技术有限公司
 * @author liuyajun, 8384503@qq.com
 * @date 2016年1月19日
 * @time 下午4:14:54
 */
public final class AccessTag extends BodyTagSupport {
    /**
     * 
     */
    private static final long serialVersionUID = 7163405251158083209L;
    private String action;
    
 
    public String getAction() {
        return action;
    }
    public void setAction(String actionId) {
        this.action = actionId;
    }
    
 
    public int doEndTag() throws JspException {
        try {
            if(this.bodyContent!=null){
                this.bodyContent.writeOut(this.bodyContent.getEnclosingWriter());
            }
        } catch (Exception e) {
            //
        }
        return EVAL_PAGE;
    }
 
    public int doStartTag() throws JspException {
        
        HttpServletRequest req = (HttpServletRequest)pageContext.getRequest();
        
        boolean output= BaseController.checkAccess(req, action);
        
        if(output){
            return EVAL_BODY_INCLUDE;
        }
        return SKIP_BODY;
    }
    
}