Which is the right function to call in a jsp page to verify the logged user is in role

送分小仙女□ 提交于 2019-12-04 05:21:40

You can use Method expression 'request.isUserInRole' in JSP to check whether current authenticated user has a role.

Test this:

<c:if test="${not empty pageContext.request.userPrincipal}">

    <c:if test="${pageContext.request.isUserInRole('ADMIN')}">

        User ${pageContext.request.userPrincipal.name} in ADMIN Group

    </c:if>

</c:if>

Note that: Calling method with/without parameters in EL expression is only supported from JavaEE6 (JSP 2.2 & EL 2.2).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!