按钮权限控制2(接上一篇)
思路:
- 对页面按钮进行权限控制,需要判断有无权限,无则隐藏
- 对jsp页面使用jstl函数库
实施过程
- 自定义函数库
新建myfn.tld
uri:页面导入时的scr引入地址
short-name:引入前缀
name:方法名
function-class:调用类名
example:使用实例
<description>用于权限控制的函数库</description>
<display-name>权限控制</display-name>
<tlib-version>1.0</tlib-version>
<short-name>myfn</short-name>
<uri>http://www.yongqiao.xyz/crm/permission</uri>
<function>
<description>
用于权限控制
</description>
<name>checkPermission</name>
<function-class>com.albert.utils.PermissionUtils</function-class>
<function-signature>boolean checkPermission(java.lang.String)</function-signature>
<example>
<c:if test="${myfn:checkPermission('com.albert.controller.EmployeeController:save')}">
</example>
</function>
- 导入自己的函数库
<%@taglib uri="http://www.yongqiao.xyz/crm/permission" prefix="myfn"%>
- jsp页面应用函数
<c:if test="${myfn:checkPermission('com.albert.controller.EmployeeController:save')}">
<a class="easyui-linkbutton" iconCls="icon-add" plain="true" data-cmd="add">新增</a>
</c:if>
<c:if test="${myfn:checkPermission('com.albert.controller.EmployeeController:update')}">
<a class="easyui-linkbutton" iconCls="icon-edit" plain="true" data-cmd="edit">编辑</a>
</c:if>
<c:if test="${myfn:checkPermission('com.albert.controller.EmployeeController:alterstate')}">
<a class="easyui-linkbutton" iconCls="icon-remove" plain="true" data-cmd="del">离职</a>
</c:if>