Struts2里用strutsmenu须注意的地方

Struts1.0中的struts menu

menu-config.xml为菜单配置文件!

在struts1.2的struts-config.xml文件中加入如下代码:

参数是:menuConfig 对应值是:菜单配置文件path!

Struts2.0 中的struts menu

menu-config.xml文件中

注意添加条目时,一定要修改Item name属性,不能重复哦,否则无法正常显示!

Struts3.0中的struts menu

struts2中配置struts-menu

以前在struts1.x中需要在struts-config.xml中配置来引入struts-menu,现在在只需要在web.xml中配置一个监听就可以了

net.sf.navigaTor.menu.MenuContextListener ----MenuContextListener.java部分源代码:-------- public class MenuContextListener implements ServletContextListener { private static Log log = LogFacTory.getLog(MenuContextListener.class); private ServletContext ctx; private String menuConfig = "/WEB-INF/menu-config.xml"; public void contextInitialized(ServletContextEvent sce) { ctx = sce.getServletContext(); if (log.isDebugEnabled()) { log.debug("Starting struts-menu initialization"); } // check for menuConfigLocation context-param String verride = sce.getServletContext().getInitParameter("menuConfigLocation"); if (override != null) { if (log.isDebugEnabled()) { log.debug("using menuConfigLocation: " + override); } this.menuConfig = override; } MenuReposiTory reposiTory = new MenuReposiTory(); reposiTory.setLoadParam(menuConfig);

对比struts1中的插件加载方式,这个舒心多了,但是struts2中菜单配置文件一定是:menu-config.xml,

struts1中则可以自己命名!

快乐要有悲伤作陪,雨过应该就有天晴。

Struts2里用strutsmenu须注意的地方

相关文章:

你感兴趣的文章:

标签云: