📄 userguide.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head><title>Struts Menu Tag Library - User Guide</title><style type="text/css" media="all"> @import url("./style/maven-base.css"); @import url("./style/maven-theme.css");</style><link rel="stylesheet" href="./style/print.css" type="text/css" media="print"></link><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></meta><meta name="author" content="Matt Raible"></meta><meta name="email" content="mraible@users.sourceforge.net"></meta></head><body class="composite"><div id="banner"><a href="http://struts-menu.sourceforge.net/" id="organizationLogo"><span class="xleft">SourceForge</span></a><a href="http://struts-menu.sourceforge.net" id="projectLogo"><img alt="Struts Menu" src="./images/sm-logo.png"></img></a><div class="clear"><hr></hr></div></div><div id="breadcrumbs"><div class="xleft"></div><div class="xright"> <a href="http://struts-menu.sourceforge.net/">Home</a> <span class="separator">|</span> <a href="http://demo.raibledesigns.com/struts-menu/index.jsp" class="externalLink" title="External Link">Demo</a> <span class="separator">|</span> <a href="http://sourceforge.net/projects/struts-menu/" class="externalLink" title="External Link">SourceForge Project Page</a> <span class="separator">|</span> <a href="http://struts-menu.cvs.sourceforge.net/struts-menu/navigator/" class="externalLink" title="External Link">Browse CVS</a> <span class="separator">|</span> <a href="http://sourceforge.net/project/showfiles.php?group_id=48726" class="externalLink" title="External Link">Download</a> <span class="separator">|</span> <a href="http://issues.appfuse.org/browse/SM" class="externalLink" title="External Link">Create an Issue</a> </div><div class="clear"><hr></hr></div></div><div id="leftColumn"><div id="navcolumn"><div id="menuReference"><h5>Reference</h5><ul><li class="none"><a href="index.html">Overview</a></li><li class="none"><strong><a href="userguide.html">User Guide</a></strong></li><li class="none"><a href="faq.html">FAQ</a></li><li class="none"><a href="devguide.html">Developer Guide</a></li><li class="none"><a href="status.html">Project Status</a></li><li class="none"><a href="security.html">Security Model</a></li></ul></div><div id="menuProject_Documentation"><h5>Project Documentation</h5><ul><li class="none"><a href="index.html">About</a></li><li class="collapsed"><a href="project-info.html">Project Info</a></li><li class="collapsed"><a href="maven-reports.html">Project Reports</a></li><li class="none"><a href="development-process.html">Development Process</a></li></ul></div><div id="legend"><h5>Legend</h5><ul><li class="externalLink">External Link</li><li class="newWindow">Opens in a new window</li></ul></div><a href="http://maven.apache.org" title="Powered by Maven" id="poweredBy"><img alt="Powered by Maven" src="./images/logos/maven-button-4.png"></img></a></div></div><div id="bodyColumn"><div class="contentBox"><div class="section"><a name="Migrating_from_1_x"></a><h2>Migrating from 1.x</h2> <p>To upgrade from Struts Menu 1.x to Struts Menu 2.x, you need to change a few things: <ul> <li>Change the URI in your taglib declaration - we removed the "1.2" part. <div class="source"><pre><%@ taglib uri="http://struts-menu.sf.net/tag" prefix="menu" %></pre></div> </li> <li>Change the <plug-in> to use the new package name "net.sf.navigator." <div class="source"><pre><plug-in className="net.sf.navigator.menu.MenuPlugIn"></pre></div> </li> <li>Change your menu-config.xml to use the new package name "net.sf.navigator." <div class="source"><pre><Displayer name="Simple" type="net.sf.navigator.displayer.SimpleMenuDisplayer"/></pre></div> </li> </ul> </p> </div><div class="section"><a name="Quick_Start"></a><h2>Quick Start</h2> <p> <ul> <li>Download the latest <a href="http://sourceforge.net/project/showfiles.php?group_id=48726" class="externalLink" title="External Link">release of struts-menu</a>. </li> <li>Unzip it to a local directory.</li> <li>Download and install <a href="http://jakarta.apache.org/tomcat" class="externalLink" title="External Link">Tomcat</a> or another Java Servlet container. </li> <li>Put struts-menu.war in Tomcat's webapps folder and start the server.</li> <li>Go to <a href="http://localhost:8080/navigator" class="externalLink" title="External Link">http://localhost:8080/struts-menu</a> </li> </ul> </p> </div><div class="section"><a name="Integrating_Struts_Menu_into_your_application"></a><h2>Integrating Struts Menu into your application</h2> <p> Struts Menu can be easily integrated into your Struts application. Here are the steps you need to take to integrate this tag library. </p> <p> Copy struts-menu.jar into your WEB-INF/lib directory. Add the plug-in settings to your struts-config.xml file. <div class="source"><pre><plug-in className="net.sf.navigator.menu.MenuPlugIn"> <set-property property="menuConfig" value="/WEB-INF/menu-config.xml"/> <!-- Default settings --></plug-in></pre></div> </p> <p style="font-style: italic">For Struts Menu 2.1+, you can put Jakarta's <a href="http://jakarta.apache.org/taglibs/doc/standard-1.0-doc/intro.html" class="externalLink" title="External Link"> Standard Tag Library JAR</a> in your WEB-INF/lib directory if you want to resolve EL expressions in menu-config.xml. </p> <ol> <li>You will need to declare your menu's attributes in a WEB-INF/menu-config.xml file. Here's a short snippet of what this might look like: <div class="source"><pre><Menu name="contactMenu" title="Contact" location="?Contact"> <Item name="email" title="E-Mail" location="?EMail"/> <Item name="phone" title="Phone" location="?Phone"/></Menu></pre></div> <br></br> For a more thorough example, look in the sample app's web/WEB-INF directory for the menu-config file and trim it down to fit your needs. For a complete list of possible attributes, see the <a href="http://struts-menu.sourceforge.net/apidocs/net/sf/navigator/menu/MenuBase.html">MenuBase class's javadocs</a>. </li> <li>Add a taglib declaration to the top of your JSP: <div class="source"><pre><%@ taglib uri="http://struts-menu.sf.net/tag" prefix="menu" %></pre></div> </li> <li>Add taglib code to render your menu in your JSP: <div class="source"><pre><menu:useMenuDisplayer name="TabbedMenu" bundle="org.apache.struts.action.MESSAGE"> <menu:displayMenu name="Home"/> <menu:displayMenu name="About"/></menu:useMenuDisplayer></pre></div> </li> </ol> <p>The <strong>name="TabbedMenu"</strong> is defined in menu-config.xml towards the top: </p> <div class="source"><pre><Displayer name="TabbedMenu" type="net.sf.navigator.displayer.TabbedMenuDisplayer"/></pre></div> <p> To use a customizeable Velocity template to render your menu, you will need to integrate Velocity into your webapp. To do this, perform the following steps: </p> <ol> <li>Make sure your menu-config.xml file has a "Velocity" displayer defined: <div class="source"><pre><Displayer name="Velocity" type="net.sf.navigator.displayer.VelocityMenuDisplayer"/></pre></div> </li> <li>Add Velocity JARs to your WEB-INF/lib directory. Download: <a href="http://www.ibiblio.org/maven/velocity/jars/velocity-1.4.jar" class="externalLink" title="External Link">velocity-1.4.jar</a> and <a href="http://www.ibiblio.org/maven/velocity-tools/jars/velocity-tools-view-1.0.jar" class="externalLink" title="External Link">velocity-tools-view-1.0.jar</a>.</li> <li>Change the displayer value to be "Velocity" in your JSP and the "config" attribute should point to a file (i.e. config="/templates/tabs.html") or config="tabs.html" if tabs.html is in your WEB-INF/classes directory. </li> </ol> <p> There are many examples of using the Velocity displayer in the <a href="http://demo.raibledesigns.com/struts-menu/index.jsp" class="externalLink" title="External Link">sample application</a> as well as <a href="http://appfuse.org" class="externalLink" title="External Link">AppFuse</a>. The example application will show you the CSS, JavaScript and image files you will need for each menu. Below are links to the Velocity templates currently available in Struts Menu. </p> <ul> <li>CoolMenus: <a href="http://demo.raibledesigns.com/struts-menu/velocity-coolmenu4.jsp" class="externalLink" title="External Link">Demo</a>, <a href="templates/coolmenus.html">Template</a> </li> <li>CSS Menu: <a href="http://demo.raibledesigns.com/struts-menu/cssHorizontal.jsp" class="externalLink" title="External Link">Demo</a>, <a href="templates/cssMenu.html">Template</a> </li> <li>NiceTabs: <a href="http://demo.raibledesigns.com/struts-menu/velocity-nicetabs.jsp?Home" class="externalLink" title="External Link">Demo</a>, <a href="templates/nicetabs.html">Template</a> </li> <li>Tabs: <a href="http://demo.raibledesigns.com/struts-menu/velocity-tabs.jsp?Home" class="externalLink" title="External Link">Demo</a>, <a href="templates/tabs.html">Template</a> </li> <li>XTree: <a href="http://demo.raibledesigns.com/struts-menu/velocity-xtree.jsp" class="externalLink" title="External Link">Demo</a>, <a href="templates/xtree.html">Template</a> </li> </ul> <p>All the relevant files you might need are available on this site:</p> <ul> <li><a href="menu-images/">Images</a></li> <li><a href="styles/">Stylesheets</a></li> <li><a href="scripts/">Scripts</a></li> <li><a href="templates/">Templates</a></li> </ul> <p>For more information on hiding/displaying menu items based on roles, see <a href="faq.html">the FAQs</a>. </p> </div><div class="section"><a name="Using_Struts_Menu_outside_of_Struts"></a><h2>Using Struts Menu outside of Struts</h2> <p>In version 2.2+, the Menu Repository can now be loaded using a MenuContextListener:</p> <div class="source"><pre><!-- - Loads the menu-config.xml for struts-menu at startup, - by default from "/WEB-INF/menu-config.xml". - To override this, add a context-param named "menuConfigLocation" - web.xml file. --><listener> <listener-class>net.sf.navigator.menu.MenuContextListener</listener-class></listener></pre></div> <p>Or if you're using <a href="http://www.springframework.org" class="externalLink" title="External Link">Spring</a>, it's even easier. Just add the following to your applicationContext.xml file:</p> <div class="source"><pre><bean id="menu" class="net.sf.navigator.menu.MenuLoader"> <property name="menuConfig" value="/WEB-INF/menu-config.xml"/> <-- default and optional --></bean></pre></div> <p>Thanks to <a href="mailto:dluputan at iquestint dot com">Dan Luputan</a> for contributed code for the MenuLoader class. </p> </div><div class="section"><a name="Building_from_Source"></a><h2>Building from Source</h2> <p> To build this project from source, perform the following steps: </p> <ol> <li>Download and install <a href="http://maven.apache.org" class="externalLink" title="External Link">Maven</a>. </li> <li>Create a MAVEN_HOME environment variable that points to where you installed Maven. Then add $MAVEN_HOME/bin to your PATH.</li> <li>Navigate to the directory you've expanded the source to and execute "maven jar" to create target/struts-menu.jar.</li> </ol> <p> To deploy the struts-menu example application, do the following:</p> <ol> <li>Download and install <a href="http://jakarta.apache.org/tomcat" class="externalLink" title="External Link">Tomcat</a>. </li> <li>Create a CATALINA_HOME environment variable that points to where you installed Tomcat.</li> <li>Execute "maven deploy" to deploy the app to Tomcat.</li> <li>Open http://localhost:8080/struts-menu in your favorite browser</li> </ol> <p>If you'd like to use Eclipse to build this project, see the Developer Guide <a href="devguide.html">Developer Guide</a>. </p> </div></div></div><div class="clear"><hr></hr></div><div id="footer"><div class="xleft"> <a href="http://sourceforge.net/projects/struts-menu" class="externalLink" title="External Link"> <img src="http://sourceforge.net/sflogo.php?group_id=48726" style="border: 0" alt="SourceForge Logo"></img></a> </div><div class="xleft">Last published: 01 June 2007 <span class="separator">|</span>燚oc for 2.4.3 </div><div class="xright">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -