仅在管理员登录时显示列

时间:2018-06-25 08:35:44

标签: javascript html ajax spring

我仅需要在管理员登录时才在表中显示特定列。如果普通用户登录,则该列应该不可见。另外,这应该是安全的,并且值在浏览器中检查时也不应该可见。

我的html如下:

<table class="table table-condensed table-striped table-bordered table-hover" id="searchResultsTable">
    <thead>
    <tr>
        <th>Channel ID</th>

        <sec:authorize access="hasAnyAuthority(@appControlSecurityService.getAdminRoleName())">
            <th>Credential</th>
        </sec:authorize>


    </tr>
    </thead>
    <tbody>
    </tbody>
</table>

相应的js代码为:

if ($('#searchResultsTable')) {


    $('#searchResultsTable').dataTable({
        "bServerSide" : true,
        "bFilter" : false,
        "sAjaxSource" : "channel-role-search-submit.json?" + $('#search_form').serialize(),
        "bSort" : false,
        "responsive": true,

        "aoColumns" : [ {
            "mData" : "channelId"
        }, {
            "mData" : "credential"
        }],

    });
}

我使用spring检查权限(是否为admin)。第二行,即“凭证”列仅对管理员可见。

0 个答案:

没有答案