文章目录
JSP自定义标签库
Shiro标签(如 shiro:principal shiro:hasRole shiro:hasPermission)可以在JSP页面中工作,那么自定义标签是如何使用的呢
Shiro标签
shiro标签的shiro.tld文件principal Tag
<tag>
<name>principal</name>
<tag-class>org.apache.shiro.web.tags.PrincipalTag</tag-class>
<body-content>JSP</body-content>
<description>Displays the user's principal or a property of the user's principal.</description>
<attribute>
<name>type</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>property</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>defaultValue</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
Shiro principal Tag实现类
package org.apache.shiro.web.tags;
import java.beans.BeanInfo;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.io.IOException;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspTagException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PrincipalTag extends SecureTag {
private static final Logger log = LoggerFactory.getLogger(PrincipalTag.class);
private String type;
private String property;
private String defaultValue;
public PrincipalTag() {
}
public String getType() {
return this.type;
}
public void setType(String type) {
this.type = type;
}
public String getProperty() {