Official English Wizard (http://struts-menu.sourceforge.net/userguide.html)
One, from 1. x upgrading to 2.X requires the following things:
1. Change the URI in your taglib declaration.
<% at Taglib uri= "Http://struts-menu.sf.net/tag" prefix= "menu"%>
2, change the <plug-in>, use the new package name "Net.sf.navigator."
<plug-in classname= "Net.sf.navigator.menu.MenuPlugIn" >
3. Change your menu-config.xml file, using the new package name "Net.sf.navigator."
<displayer name= "Simple"
Type= "Net.sf.navigator.displayer.SimpleMenuDisplayer"/>
Second, Quick start:
1, download the latest struts-menu version;
2, unpacking to the local directory;
3. Download Tomcat or other servlet containers;
4. Put the Struts-menu.war package into the Wabapps directory of the Tomcat installation directory and restart the Tomcat service.
5. Open htpp://localhost:8080/struts-menu/
Third, integrate struts menu into your application:
Struts menu can be easily integrated into your struts application, it can also be integrated into a non-struts application, but I do not like to do so, so there is no corresponding tutorial. This will take you through the tag library in one step.
You need to put Struts-menu.jar in your Web-inf/lib directory. Then use the URI tag to declare the tag library that you want to use in your JSP file.
If you use Struts Menu 2.1, you will also need to Jakarta ' s standard Tag Library jar package into your Web-inf/lib directory. Download Address: Http://ibiblio.org/maven/taglibs/jars/standard-1.0.4.jar, this file includes routine war package files and binary release packages.
1. Put the Struts-menu.jar package into the Web-inf/lib directory of your application.
2. Add plug-in settings to your Struts-config.xml file.
<plug-in classname= "Net.sf.navigator.menu.MenuPlugIn" >
<set-property property= "Menuconfig"
Value= "/web-inf/menu-config.xml"/>
</plug-in>
3. You will need to define your menu in the/web-inf/menu-config.xml file of your application, which provides a simple snippet:
<menu name= "Contactmenu" title= "Contact" location= "? Contact ">
<item name= "Email" title= "e-mail" location= "? EMail "/>
<item name= "Phone" title= "phone" location= "? Phone "/>
</Menu>
For more comprehensive routines, check out the Menu-config.xml file in the application's Web/web-inf directory, and you can intercept a menu as you need it. A complete list of properties can be viewed Menubase class ' s Javadocs (http://struts-menu.source......avigator/menu/MenuBase.html).
4. Add the Taglib statement at the top of your JSP file:
<% at Taglib uri= "Http://struts-menu.sf.net/tag" prefix= "menu"%>
5. Add the Taglib code to the location in your JSP file where you want to place the menu:
<menu:usemenudisplayer name= "Tabbedmenu"
bundle= "Org.apache.struts.action.MESSAGE" >
<menu:displaymenu name= "Home"/>
<menu:displaymenu name= "About"/>
</menu:useMenuDisplayer>
The attribute name= "Tabbedmenu" is defined at the top of the Menu-config.xml file:
<displayer name= "Tabbedmenu"
Type= "Net.sf.navigator.displayer.TabbedMenuDisplayer"/>
In fact, to this step you can add the corresponding menu in your JSP file, but there is no combination of velocity. Multiple displayer can be defined on the head of the Menu-config.xml file, each displayer has a name and type attribute, and the Name property corresponds to the Name property of the Menu:usemenudisplayer tag in the JSP file. That is, the style definition is defined in the Type property, and the type attribute is a class. The Name property in the menu definition in the Menu-config.xml file corresponds to the Name property of the Menu:displaymenu label in the JSP file. )
Using a custom velocity template to implement your menu, you need to integrate the velocity into your Web application. If you need to do this, complete the following steps:
1, make sure your menu-config.xml file has the displayer definition of "velocity":
<displayer name= "Velocity"
type= "Net.sf.navigator.displayer.VelocityMenuDisplayer"/>
2. Join Velocity's jars package into your web-inf/lib directory, download Velocity-1.4-rc1.jar (http://www.ibiblio.org/ma......y/jars/ Velocity-1.4-rc1.jar) and Velocity-tools-view-1.0.jar (Http://www.ibiblio.org/ma......velocity-tools-view-1.0.jar).
3, join GLOBALMACROS.VM (http://cvs.sourceforge.net/viewcvs.py/*checkout*/struts-menu/navigator/web/web-inf/ classes/globalmacros.vm?content-type=text%2fplain&rev=1.1 (right-click Save)) to your Web-inf/lib directory.
4, change the value of Displayer in your JSP file to "Velocity", "config" attribute to a file (such as config= "/templates/tabs.html") or if tabs.htm in your web-inf/ Classes directory, you can set config= "tabs.html".
Here are some examples of displayer using velocity, which can be viewed in sample application (http://demo.raibledesigns.com/struts-menu/index.jsp). It always displays css,javascript and image files when your menu is needed. Here are some examples of the velocity templates used in the current Struts menu:
Coolmenus:demo (http://demo.raibledesigns......menu/velocity-coolmenu4.jsp),
Template (http://struts-menu.sourceforge.net/templates/coolmenus.html)
Nicetabs:demo, Template
Tabs:demo, Template
Xtree:demo, Template
All relevant useful files can be downloaded at the following sites if you need them:
Images (http://struts-menu.sourceforge.net/menu-images/)
StyleSheets (http://struts-menu.sourceforge.net/styles/)
Scripts (http://struts-menu.sourceforge.net/scripts/)
Templates (http://struts-menu.sourceforge.net/templates/)
For more information on roles-based display/hide menus, see FAQs (http://struts-menu.sourceforge.net/faq.html).
Iv. use struts Menu outside struts:
in version 2.2, menu repository can be loaded with Menucontextlistener:
<!--
-Loads The Menu-config.xml for Struts-menu at startup,
– By default from "/web-inf/me Nu-config.xml ".
-To override this, add a context-param named "Menuconfiglocation"
-WEB.XM L file.
-->
<listener>
<listener-class> Net.sf.navigator.menu.menucontextlistener</listener-class>
</listener>
Or if you use spring, it's even easier. Just add the following section to your Applicationcontext.xml file:
<bean id= "Menu" class= "Net.sf.navigator.menu.MenuLoader" >
<property name= "Menuconfig" >
<value>/WEB-INF/menu-config.xml</value>
</property>
</bean>
<!--the Menuconfig property was an optional attribute. It is set to
/web-inf/menu-config.xml by default. -
Thanks Dan Luputan for providing the source code for the Menuloader class.
V. Compiling from source file:
To compile this project from a source file, perform the following steps:
1. Download and install maven (http://maven.apache.org/);
2. Create an environment variable maven_home indicate your MAVEN installation directory and add $maven_home/bin to your PATH variable;
3, manipulate this directory you can expand the source code, execute "Maven.jar" create Target/struts-menu.jar.
To expand the Struts-menu routine, you need the following steps:
1, download and install tomcat;
2. Create an environment variable catalina_home indicates the installation directory of your Tomcat;
3. Implement "Maven deploy" to expand the application into Tomcat;
4. Open the Http://localhost:8080/struts-menu in your favorite browser.
If you prefer to use eclipse development projects, refer to this development wizard (http://struts-menu.sourceforge.net/devguide.html).