-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPermissionTag.java
More file actions
78 lines (61 loc) · 1.58 KB
/
Copy pathPermissionTag.java
File metadata and controls
78 lines (61 loc) · 1.58 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package com.caozj.taglib;
import java.io.IOException;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.caozj.framework.session.SessionUtil;
/**
* 判断用户是否有访问某个url的权限的标签
*
* @author caozj
*
*/
public class PermissionTag extends SuperTag {
private static final long serialVersionUID = 8989690814100321160L;
private static final Log logger = LogFactory.getLog(PermissionTag.class);
private String url;
private HttpSession session;
private String content;
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public HttpSession getSession() {
return session;
}
public void setSession(HttpSession session) {
this.session = session;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
@Override
public int doEndTag() throws JspException {
if (getBodyContent() != null) {
String body = getBodyContent().getString();
if (StringUtils.isNotBlank(body)) {
content = body;
}
}
if (StringUtils.isBlank(content)) {
return EVAL_PAGE;
}
JspWriter out = pageContext.getOut();
try {
if (SessionUtil.hasPermission(session, url)) {
out.print(content);
}
} catch (IOException e) {
logger.error(e);
}
return EVAL_PAGE;
}
}