我有以下代码
<body>
<%
String loggedInUserName = (String) request.getAttribute("loggedInUserName");
%>
<%
String userRole = "lead";
%>
<%
if (loggedInUserName.equals(userRole)) { %>
<%@ include file="tabs.jsp"%>
<a href="dataOwner-index.html" style="visibility: hidden"></a>
<a href="dataOwner-riskAssessmentCompliance.html"style="visibility: hidden"></a>
<a href="security_setup.html" style="visibility: hidden"></a>
<%
}
%>
tabs.jsp包含
<div class="tslcNav" role="navigation">
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="index.html">Home</a></li>
<li><a href="mngPost.html">Manage Portfolio</a></li>
<li><a href="riskAssesment.html">Risk Assesment</a></li>
<li><a href="securitySetup.html">Security Setup</a></li>
<li><a href="dataOwner-index.html">Home</a></li>
<li><a href="dataOwner-riskAssessmentCompliance.html">Assessment Workbook</a></li>
<li><a href="security_setup.html">Security Setup</a></li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
这段代码有什么问题?显示所有标签。我想只显示那些与铅相关的标签我想隐藏其他链接,即标签。
答案 0 :(得分:0)
它会显示所有标签,因为您要将整个tabs.jsp
包含在此行
&lt;%@ include file =&#34; tabs.jsp&#34;%
在您的标签后,您在生成的HTML页面中添加了三个具有隐藏样式的新<a>
之后的三行。
解决此问题需要首先删除这些行
<a href="dataOwner-index.html" style="visibility: hidden"></a>
<a href="dataOwner-riskAssessmentCompliance.html"style="visibility: hidden"></a>
<a href="security_setup.html" style="visibility: hidden"></a>
仅应用仅在您不希望在tabs.jsp
中显示的标签上隐藏的样式,您可以使用el
这样做
<li><a href="index.html">Home</a></li>
<li><a href="mngPost.html">Manage Portfolio</a></li>
<li><a href="riskAssesment.html">Risk Assesment</a></li>
<li><a href="securitySetup.html">Security Setup</a></li>
<li><a href="dataOwner-index.html" ${ loggedInUserName eq userRole ? 'style="visibility: hidden"' : '' }>Home</a></li>
<li><a href="dataOwner-riskAssessmentCompliance.html" ${ loggedInUserName eq userRole ? 'style="visibility: hidden"' : '' }>Assessment Workbook</a></li>
<li><a href="security_setup.html" ${ loggedInUserName eq userRole ? 'style="visibility: hidden"' : '' }>Security Setup</a></li>