posts - 9,comments - 3,trackbacks - 0
  1. Background

         Usually,When we develop our web application,we need create menu.We can use Javascript to design web menu,but if thus,we have to compile many codes,and our application hasn't good  revisability and maintainability .Struts-menu provides us a convenient web menu design way,we can put our web menu data in  a menu-config.xml configuration file,and read the data with struts-menu lable.

   2.  Struts  Menu Example
        You can go here to see the example;
        Or download the example application,follow the below instruction:  
               Unzip it to a local directory.  
               Download and install Tomcat or another Java Servlet container.  
               Put struts-menu.war in Tomcat's webapps folder and start the server. 
               Go to http://localhost:8080/struts-menu 

 3.   Integrating Struts Menu into your application

      1.  Place struts-menu-2.3.jar into your app's WEB-INF/lib directory.(maybe you also need put common-lang.jar)
      2.  Place struts-menu.tld,and struts-menu-el.tld into your app's WEB-INF directory
      3.  Copy the common,images,scripts,template,styles directory from the above struts-menu.war exmaple application  to your web directory.(if use Myeclipse,put those directorys in webroot directory)
      4.  Add the plug-in settings to your struts-config.xml file.                 
               <plug-in className="">
                         <set-property property="menuConfig"
        5.  You will need to declare your menu's attributes in a your App /WEB-INF/menu-config.xml file.Here's  a short  snippet of what might look like:        
             <Menu name="contactMenu" title="Contact" location="?Contact">
                  <Item name="email" title="E-Mail" location="?EMail"/>
                  <Item name="phone" title="Phone" location="?Phone"/>
         6.   Add a taglib declaration to the top of your JSP: 

        <%@ taglib uri="" prefix="menu" %>

        7.  Add taglib code to render your menu in your JSP: 

               <menu:useMenuDisplayer name="TabbedMenu"
                    <menu:displayMenu name="Home"/>
                    <menu:displayMenu name="About"/>
       8.  Below is a whole test.jsp
            <%@ page contentType="text/html; charset=UTF-8" %>
            <%@ taglib uri="" prefix="html" %>
            <%@ taglib uri="" prefix="menu" %>
             <html:base />
                 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

                 <link rel="stylesheet" type="text/css" media="screen"
                               href="styles/global.css" />
                      <link rel="stylesheet" type="text/css" media="screen"
                              href="styles/coolmenu.css" />
                <script type="text/javascript" src="scripts/coolmenus4.js"></script>
                <script type="text/javascript" src="scripts/cm_addins.js"></script>
               <script type="text/javascript" src="scripts/coolmenu4-config.js"></script> 
               <menu:useMenuDisplayer name="CoolMenu4"
                   <menu:displayMenu name="Home"/>
                  <menu:displayMenu name="About"/>


posted on 2006-04-05 15:23 freefly 阅读(455) 评论(0)  编辑  收藏 所属分类: Struts