【发布时间】:2016-11-23 23:48:15
【问题描述】:
我正在使用 MySQL 制作 JSP/Servlet CRUD。我目前在我的项目中有两个角色:经理和员工。我想根据这些角色显示不同的数据。如何在不使用 scriptlet 的情况下访问 request.isUserInRole() 方法?我听说使用小脚本很糟糕。
我暂时有如下代码:
<c:if <%request.isUserInRole("manager");%>=true>
<!-- Display something -->
<c:if <%request.isUserInRole("employee");%>=true>
<!-- Display something -->
但我得到一个错误:
HTTP Status 500 - /protected/listUser.jsp (line: 97, column: 9) Unterminated &lt;c:if tag
这可能是 JSTL 与 scriptlet 混合的一些问题。
如何在我的 JSP 页面中仅使用 JSTL 访问 isUserInRole() 方法?
【问题讨论】: