1. 用Jbuilder2005建一个新的Project :NewMenu
2. 在Project创建一个Web Module :menu,在项目中添加Struts1.2.4,Log4j,Velocity1.4,Commons,JSTL,Struts-Menu2.3支持.
3. 修改Struts-Config文件如下图:
clip_image002[4]
4. 在WEB-INF下添加menu-config.xml文件
――――――――――――――――――――――――――――――――――――
<?xml version="1.0" encoding="UTF-8" ?>
<MenuConfig>
<Displayers>
<Displayer name="DropDown"
type="net.sf.navigator.displayer.DropDownMenuDisplayer"/>
<Displayer name="Simple"
type="net.sf.navigator.displayer.SimpleMenuDisplayer"/>
<Displayer name="CoolMenu"
type="net.sf.navigator.displayer.CoolMenuDisplayer"/>
<Displayer name="CoolMenu4"
type="net.sf.navigator.displayer.CoolMenuDisplayer4"/>
<Displayer name="MenuForm"
type="net.sf.navigator.example.PermissionsFormMenuDisplayer"/>
<Displayer name="ListMenu"
type="net.sf.navigator.displayer.ListMenuDisplayer"/>
<Displayer name="TabbedMenu"
type="net.sf.navigator.displayer.TabbedMenuDisplayer"/>
<Displayer name="Velocity"
type="net.sf.navigator.displayer.VelocityMenuDisplayer"/>
</Displayers>
<Menus>
<Menu name="Home" title="Contact" location="?Contact">
<Item name="e-mail" title="E-Mail" location="?[url]www.163.com[/url]"/>
<Item name="phone" title="Phone" location="www.sina.com"/>
</Menu>
<Menu name="About" title="Contact" location="?Contact">
<Item name="e-mail" title="E-Mail" location="www.163.com"/>
<Item name="phone" title="Phone" location="www.sina.com"/>
</Menu>
</Menus>
</MenuConfig>
―――――――――――――――――――――――――――――――――――――
此处黄色部分将同JSP页面上的<menu:displayMenu name="Home"/>
5. 创建index.jsp页面:
<%@ page contentType="text/html; charset=GB2312" %>
<%@ taglib uri="http://struts-menu.sf.net/tag" prefix="menu" %>
<html>
<head>
<title>
index
</title>
</head>
<body bgcolor="#ffffff">
<h1>
JBuilder Generated JSP
<menu:useMenuDisplayer name="Simple">
<menu:displayMenu name="Home"/>
<menu:displayMenu name="About"/>
</menu:useMenuDisplayer>
</h1>
</body>
</html>
6. 最后的Web.xml文件内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>menu</display-name>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>TrackerRes</param-value>
</context-param>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>application</param-name>
<param-value>ApplicationResources</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<taglib>
<taglib-uri>[url]http://java.sun.com/jstl/core</taglib-uri>[/url]
<taglib-location>/WEB-INF/c.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>[url]http://java.sun.com/jstl/core_rt</taglib-uri>[/url]
<taglib-location>/WEB-INF/c-rt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>[url]http://java.sun.com/jstl/xml</taglib-uri>[/url]
<taglib-location>/WEB-INF/x.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>[url]http://java.sun.com/jstl/xml_rt</taglib-uri>[/url]
<taglib-location>/WEB-INF/x-rt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>[url]http://java.sun.com/jstl/fmt</taglib-uri>[/url]
<taglib-location>/WEB-INF/fmt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>[url]http://java.sun.com/jstl/fmt_rt</taglib-uri>[/url]
<taglib-location>/WEB-INF/fmt-rt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>[url]http://java.sun.com/jstl/sql</taglib-uri>[/url]
<taglib-location>/WEB-INF/sql.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>[url]http://java.sun.com/jstl/sql_rt</taglib-uri>[/url]
<taglib-location>/WEB-INF/sql-rt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>[url]http://struts-menu.sf.net/tag</taglib-uri>[/url]
<taglib-location>/WEB-INF/struts-menu.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>[url]http://struts-menu.sf.net/tag-el</taglib-uri>[/url]
<taglib-location>/WEB-INF/struts-menu-el.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-template.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-template.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
</taglib>
</web-app>
7. 拷贝struts-menu.war下的templates,images,scripts,styles文件夹到你的web目录中,跟web-inf在同一级目录下,把log4j.properties和globalMacros.vm放到Src根目录文件夹下,把所有相关的tld文件考到WEB-INF下,包括Struts的,Struts-menu的,JSTL的
8.运行,就OK了!
注意,在用TabbedMenu时,就不要加其他的menu的样式表和JS了,不然不能显示出页面样式,如,加入了list样式,再加入tabbed样式,则会只显示list样式的,即就近原则。