• OpenCMS创建导航条


    OpenCMS首页导航条代码,在VFS中的/system/modules/org.opencms.welcome/elements/welcome_nav.jsp

     1 <%@ page import="org.opencms.jsp.*" %><%   
    2
    3 /*
    4 * This is a simple example on how to build a dynamic navigation using JSP in OpenCms.
    5 * It serves the purpose of demonstrating
    6 * the general way to build a dynamic navigation using OpenCms resource properties.
    7 */
    8
    9 // Create a JSP action element
    10 CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, response);
    11
    12 // Some shortcuts to often used Strings
    13 String filename = cms.getRequestContext().getUri(); /*filename为页面名,比如url为http://localhost:8080/opencms/opencms/index.jsp,filename为/index.jsp*/
    14 // List of all pages / subfolders (sorted by NavPos property)
    15 java.util.List list = cms.getNavigation().getNavigationForFolder(); //得到同层目录的所有文件的list
    16 java.util.Iterator i = list.iterator();
    17
    18 // Now build the navigation
    19 out.println("<p class=\"small\">Navigation: ");
    20
    21 while (i.hasNext()) {
    22 CmsJspNavElement ne = (CmsJspNavElement)i.next();
    23 if (! ne.getResourceName().equals(filename)) {
    24 out.println("<a href=\"" +
    25 cms.link(ne.getResourceName()) + "\">"
    26 + ne.getNavText() + "</a>"); //ne.getNavText()为的navigationtext属性
    27 } else {
    28 out.println(ne.getNavText()); //页面本身
    29 }
    30 if (i.hasNext()) {
    31 out.println(" | ");
    32 }
    33 }
    34 out.println("</p>");
    35 %>



  • 相关阅读:
    阿里巴巴excel工具easyexcel 助你快速简单避免OOM
    IoC和AOP的理解
    WebSocket和kafka实现数据实时推送到前端
    Swagger使用指南
    转载:对于马老师对996的看法
    基础:新建个maven项目
    eclipse集成lombok
    多线程
    jar包

  • 原文地址:https://www.cnblogs.com/zengyou/p/2185316.html
Copyright © 2020-2023  润新知