📄 menuloader.java
字号:
package net.sf.navigator.menu;import javax.servlet.ServletException;import net.sf.navigator.util.LoadableResourceException;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.springframework.context.ApplicationContextException;import org.springframework.web.context.support.WebApplicationObjectSupport;/** * This loader is available for those that use the Spring Framework. To * use it, simply configure it as follows in your applicationContext.xml file. * </p> * <pre> * <bean id="menu" class="net.sf.navigator.menu.MenuLoader"> * <property name="menuConfig"> * <value>/WEB-INF/menu-config.xml</value> * </property> * </bean> * </pre> * <p>The menuConfig property is an optional attribute. It is set to * /WEB-INF/menu-config.xml by default.</p> * * @author Matt Raible */public class MenuLoader extends WebApplicationObjectSupport { private static Log log = LogFactory.getLog(MenuLoader.class); /** Configuration file for menus */ private String menuConfig = "/WEB-INF/menu-config.xml"; /** * Set the Menu configuration file * @param menuConfig the file containing the Menus/Items */ public void setMenuConfig(String menuConfig) { this.menuConfig = menuConfig; } /** * Initialization of the Menu Repository. * @throws org.springframework.context.ApplicationContextException if an error occurs */ protected void initApplicationContext() throws ApplicationContextException { try { if (log.isDebugEnabled()) { log.debug("Starting struts-menu initialization"); } MenuRepository repository = new MenuRepository(); repository.setLoadParam(menuConfig); repository.setServletContext(getServletContext()); try { repository.load(); getServletContext() .setAttribute(MenuRepository.MENU_REPOSITORY_KEY, repository); if (log.isDebugEnabled()) { log.debug("struts-menu initialization successful"); } } catch (LoadableResourceException lre) { throw new ServletException("Failure initializing struts-menu: " + lre.getMessage()); } } catch (Exception ex) { throw new ApplicationContextException("Failed to initialize Struts Menu repository", ex); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -