📄 faq.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 - Developer 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 AT 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"><a href="userguide.html">User Guide</a></li><li class="none"><strong><a href="faq.html">FAQ</a></strong></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="Frequently_Asked_Questions"></a><h2>Frequently Asked Questions</h2> <p><strong>Q:</strong> I get the following error when I try to access a JSP with a menu: <div class="source"><pre>org.apache.jasper.JasperException: Could not obtain the menu repository</pre></div> </p> <p><strong>A:</strong> Check your struts-config.xml to make sure the plug-in settings are correct. They should be similar to the following: <div class="source"><pre><plug-in className="net.sf.navigator.menu.MenuPlugIn"> <set-property property="menuConfig" value="/WEB-INF/menu-config.xml"/></plug-in><!-- The menuConfig property is an optional attribute. It is set to /WEB-INF/menu-config.xml by default. --></pre></div> </p> <p><strong>Q:</strong> How do I show/hide menus/items based on roles?</p> <p><strong>A:</strong> Add permissions="rolesAdapter" to your <menu:useMenuDisplayer> tag. Then in your menu-config.xml, put a comma-delimited list of roles that are allowed to view this menu or item. For more information, see the <a href="security.html">security model page</a>. </p> <p><strong>Q:</strong> Can I use Struts Menu outside of a Struts Application?</p> <p><strong>A:</strong> 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>NOTE: You'll need version 2.3+ if you want to remove struts.jar from your project. You can also configure the repository to be loaded by <a href="http://www.springframework.org" class="externalLink" title="External Link">Spring</a>. Just add the following to your context file: <div class="source"><pre><bean id="menu" class="net.sf.navigator.menu.MenuLoader"> <property name="menuConfig"> <value>/WEB-INF/menu-config.xml</value> </property></bean><!-- The menuConfig property is an optional attribute. It is set to /WEB-INF/menu-config.xml by default. --></pre></div> </p> <p>Thanks to <a href="mailto:dluputan at iquestint dot com">Dan Luputan</a> for contributed code for the MenuLoader class.</p> <p>I also added support for regular ol' ResourceBundles and, if you're using the EL tag - JSTL's ResourceBundle. Here's how it all works:</p> <p style="margin-left: 30px; font-style: italic">The EL tag defaults to JSTL's ResourceBundle if no "bundle" attribute is specified, and to Struts' MessageResources if that's not found. The regular tag defaults to Struts' MessageResources if no bundle is specified. All bad bundle attributes result in a log.error() rather than a JspException.</p> <p><strong>Q:</strong> How do I create a menu dynamically from a database?</p> <p><strong>A:</strong> The example app has a <a href="http://demo.raibledesigns.com/struts-menu/dynamicMenu.jsp" class="externalLink" title="External Link">howto for dynamic menus</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 + -