如何自定义JSTL标签(在oa系统中用JSTL函数解决即时认证问题)
2011-11-10 17:52
786 查看
刚学习了JSTL函数的创建,现在在这小结一下:
1.建一个类如:
package org.yebing.oa.web;
import org.yebing.oa.manager.ACLManager;
public class SecurityFunctions {
private static ACLManager aclManager;
public static boolean hasPermission(int userId,String resourceSn,int permission){
return aclManager.hasPermissionByResourceSn(userId, resourceSn, permission);
}
//由于spring不支持static类型的set方法注入
public void setAclManager(ACLManager aclManager) {
SecurityFunctions.aclManager = aclManager;
}
}
注意:1.方法必须为是static
2.spring不支持static类型的set方法注入
2.在web-inf下建一my.tld文件:
<?xml version="1.0" encoding="UTF-8" ?>
<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2eehttp://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0">
<tlib-version>1.0</tlib-version>
<short-name>my</short-name>
<uri>http://www.yebing.com/oa/functions</uri>
<function>
<name>hasPermission</name>
<function-class>org.yebing.oa.web.SecurityFunctions</function-class>
<function-signature>boolean hasPermission(int, java.lang.String,int)</function-signature>
</function>
</taglib>
3.再在web.xml中配置此自定义的标签:
<jsp-config>
<taglib>
<taglib-uri>http://www.yebing.com/oa/myfunctions</taglib-uri>
<taglib-location>/WEB-INF/my.tld</taglib-location>
</taglib>
</jsp-config>
4.还需在使用的jsp页面上加上标签声明:
<%@ taglib prefix="my" uri="http://www.yebing.com/oa/myfunctions" %>
5.由于我使用到了spring开发系统,加上在SecurityFunctions用到了aclManager所以要在spring中注入:
<bean id="sucurityFunctions" class="org.yebing.oa.web.SecurityFunctions">
<property name="aclManager" ref="aclManager"></property>
</bean>
1.建一个类如:
package org.yebing.oa.web;
import org.yebing.oa.manager.ACLManager;
public class SecurityFunctions {
private static ACLManager aclManager;
public static boolean hasPermission(int userId,String resourceSn,int permission){
return aclManager.hasPermissionByResourceSn(userId, resourceSn, permission);
}
//由于spring不支持static类型的set方法注入
public void setAclManager(ACLManager aclManager) {
SecurityFunctions.aclManager = aclManager;
}
}
注意:1.方法必须为是static
2.spring不支持static类型的set方法注入
2.在web-inf下建一my.tld文件:
<?xml version="1.0" encoding="UTF-8" ?>
<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2eehttp://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0">
<tlib-version>1.0</tlib-version>
<short-name>my</short-name>
<uri>http://www.yebing.com/oa/functions</uri>
<function>
<name>hasPermission</name>
<function-class>org.yebing.oa.web.SecurityFunctions</function-class>
<function-signature>boolean hasPermission(int, java.lang.String,int)</function-signature>
</function>
</taglib>
3.再在web.xml中配置此自定义的标签:
<jsp-config>
<taglib>
<taglib-uri>http://www.yebing.com/oa/myfunctions</taglib-uri>
<taglib-location>/WEB-INF/my.tld</taglib-location>
</taglib>
</jsp-config>
4.还需在使用的jsp页面上加上标签声明:
<%@ taglib prefix="my" uri="http://www.yebing.com/oa/myfunctions" %>
5.由于我使用到了spring开发系统,加上在SecurityFunctions用到了aclManager所以要在spring中注入:
<bean id="sucurityFunctions" class="org.yebing.oa.web.SecurityFunctions">
<property name="aclManager" ref="aclManager"></property>
</bean>
相关文章推荐
- 在oa系统中用JSTL函数解决即时认证问题
- 如何解决自定义函数问题
- 如何自定义JSTL标签与SpringMVC 标签的属性中套JSTL标签报错的解决方法
- OA系统使用过程中遇到安全问题如何解决
- JSTL自定义函数完成ACL即时认证
- eCos系统无法正确链接到在C++源文件中自定义的cyg_user_start函数的问题和解决办法
- 使用jstl标签过程中出现问题的解决
- Python:通过自定义系统级快捷键来控制程序开始或停止记录日志(使用小技巧解决一个貌似无解的问题)
- 解决django中内置身份认证表单无法自定义渲染的问题
- 高手分享:快速处理IE如何打开网页的问题——认证系统
- 如何解决deepin系统下Tomcat安装问题
- 自定义JSP的 JSTL标签函数过程
- linux下如何解决jvm执行取得的时间和系统时间不一致的问题
- 如何解决笔记本装系统时提示“缺少所需的cd/dvd驱动器设备驱动程序”的问题
- 自定义JSTL标签函数步骤详解
- 如何衡量OA系统的质量问题
- 2个自定义的PHP in_array 函数,解决大量数据判断in_array的效率问题
- 2个自定义的PHP in_array 函数,解决大量数据判断in_array的效率问题
- zendstudio 函数跳转问题如何解决
- [解决]maven打包如何指定自定义外部包的问题