【问题标题】:Using EL in <jsp:include> tag在 <jsp:include> 标记中使用 EL
【发布时间】:2012-07-25 05:34:29
【问题描述】:

我有一个 jsf 1.2/rich faces 3.2.2 项目(使用 java 6)。我想根据登录用户的类型有条件地显示菜单栏。从问题How to conditionally include a file in my template using JSF and Facelets? 我尝试了以下操作:-

...
<td valign="top" align="left" height="100%">
</f:verbatim> 
 <jsp:include page="../Menu${authenticateBean.menuSuffix}.jsp" /> <f:verbatim></td>
...
i also tried 
  <jsp:include page="../Menu#{authenticateBean.menuSuffix}.jsp" />
...

其中 authenticateBean.menuSuffix 是一个字符串,它将返回“A”或“B”,最终,理论上“MenuA.jsp”或“MenuB.jsp”页面应该包含在我的页面中。但我收到以下错误

javax.servlet.ServletException: File &quot;/pages/includes/LeftPan.jsp&quot; not found

帮助。请。

【问题讨论】:

    标签: el jsf-1.2 jspinclude


    【解决方案1】:

    这就是我的管理方式。如果没有人需要,可以将其作为答案……

    <%
    AuthenticateBean authBean=
    ((AuthenticateBean)FacesUtils.getManagedBean(AuthenticateBean.MANAGED_NAME));
        String panSuffix = authBean.getPanSuffix();
    String impPage = "../includes/Menu"+ panSuffix +".jsp";
     %>
     .
     .
     .  
    <jsp:include page="<%= impPage %>" />
    

    在 getPanSuffix() 中,我放置了检查登录用户类型并相应返回字符串的业务逻辑。对于类型“A”的用户。 MenuA.jsp 将显示,对于类型“B”的用户 MenuB.jsp 将显示。可能是一种原始的做事方式,但对我有用。 谢谢大家。

    【讨论】:

      猜你喜欢
      • 2014-07-26
      • 2012-08-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-09
      • 2011-03-30
      • 2011-03-10
      • 2014-09-07
      相关资源
      最近更新 更多