📄 shopmenu.java
字号:
package com.publish.shop.taglib;import java.util.List;import java.util.ArrayList;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpSession;import javax.servlet.jsp.JspException;import javax.servlet.jsp.JspTagException;import javax.servlet.jsp.JspWriter;import javax.servlet.jsp.tagext.TagSupport;import com.publish.shop.util.javabeans.SessionWrapper;import com.publish.shop.util.javabeans.Constants;import com.publish.shop.util.javabeans.Utility;import com.publish.shop.util.javabeans.Debug;public class ShopMenu extends TagSupport { private String csContextPath = ""; private String csImgPath = ""; private int width = 0; private int widthsubmenu = 0; private int widthsubsubmenu = 0; private int numberofsubmenus = 0; private int numberofsubsubmenus = 0; private List listMenu = null; private List listSubMenu = null; private List listSubSubMenu = null; public ShopMenu() { } public int doStartTag() throws JspException { try { HttpServletRequest req = (HttpServletRequest)pageContext.getRequest(); csContextPath = req.getContextPath(); csImgPath = csContextPath + "/images/"; HttpSession lSession = req.getSession(); SessionWrapper lSessionWrapper = (SessionWrapper)lSession.getAttribute(Constants.Session_Wrapper); String lsSelectedMenu = ""; String lsSelectedSubMenu = ""; String lsSelectedSubSubMenu = ""; if (lSession.getAttribute(Constants.SelectedMenu) != null) lsSelectedMenu = (String)lSession.getAttribute(Constants.SelectedMenu); if (lSession.getAttribute(Constants.SelectedSubMenu) != null) lsSelectedSubMenu = (String)lSession.getAttribute(Constants.SelectedSubMenu); if (lSession.getAttribute(Constants.SelectedSubSubMenu) != null) lsSelectedSubSubMenu = (String)lSession.getAttribute(Constants.SelectedSubSubMenu); Menu lMenu = null; listMenu = (ArrayList)lSession.getAttribute(Constants.Menu_Config_Session); createLogo(); createAllMenu(lsSelectedMenu); createAllSubMenu(lsSelectedSubMenu); } catch(Exception ex) { ex.printStackTrace(); throw new JspTagException(ex.getMessage()); } return 0; } private void createAllMenu(String selectedMenu) throws Exception{ JspWriter jspwriter = pageContext.getOut(); if(listMenu==null || listMenu.size()==0) return ; jspwriter.write("<TABLE bgColor=#0033cc border=0 cellPadding=0 cellSpacing=0 width=\"100%\">"); jspwriter.write("<TBODY><TR><TD><TABLE border=0 cellPadding=0 cellSpacing=0><TBODY><TR>"); for(int i=0;i<listMenu.size();i++){ jspwriter.write("<TD><IMG alt=\"\" border=0 height=1 src=\""+csImgPath+ "dot(1).gif\" width=18></TD>"); Menu lMenu = (Menu)listMenu.get(i); if(selectedMenu.equals(lMenu.getMenuID())){ listSubMenu = lMenu.getChilds(); jspwriter.write("<TD><A href=\""+csContextPath+lMenu.getMenuLink()+"\"><IMG alt=\"\" border=0 src=\""+csImgPath+lMenu.getMenuSelImg()+"\"></A></TD>"); Debug.println("<TD><A href=\""+csContextPath+lMenu.getMenuLink()+"\"><IMG alt=\"\" border=0 src=\""+csImgPath+lMenu.getMenuSelImg()+"\"></A></TD>"); }else{ jspwriter.write("<TD><A href=\""+csContextPath+lMenu.getMenuLink()+"\"><IMG alt=\"\" border=0 src=\""+csImgPath+lMenu.getMenuImg()+"\"></A></TD>"); Debug.println("<TD><A href=\""+csContextPath+lMenu.getMenuLink()+"\"><IMG alt=\"\" border=0 src=\""+csImgPath+lMenu.getMenuSelImg()+"\"></A></TD>"); } } jspwriter.write("</TR></TBODY></TABLE></TD></TR></TBODY></TABLE>"); } private void createAllSubMenu(String selectedSubMenu) throws Exception{ if(listSubMenu==null || listSubMenu.size()==0) return; JspWriter jspwriter = pageContext.getOut(); jspwriter.write("<TABLE border=0 cellPadding=0 cellSpacing=0 width=\"100%\"><TBODY>"); jspwriter.write("<TR><TD bgColor=#cccccc><IMG alt=\"\" border=0 height=5 src=\"" + csImgPath + "dot(1).gif\" width=1></TD></TR>"); jspwriter.write("<TR><TD bgColor=#cccccc vAlign=bottom><TABLE border=0 cellPadding=0 cellSpacing=0><TBODY><TR>"); jspwriter.write("<TD><IMG alt=\"\" border=0 height=1 src=\""+csImgPath+"dot(1).gif\" width=20></TD><TD align=middle>"); for(int i=0;i<listSubMenu.size();i++){ Menu lMenu = (Menu)listSubMenu.get(i); if(selectedSubMenu.equals(lMenu.getMenuID())){// listSubSubMenu = lMenu.getChilds(); jspwriter.write("<A href=\""+csContextPath+lMenu.getMenuLink()+"\"><B style=\"TEXT-DECORATION: underline\">"+lMenu.getMenuName()+"</B></A>"); }else{ jspwriter.write("<A href=\""+csContextPath+lMenu.getMenuLink()+"\">"+lMenu.getMenuName()+"</A>"); } if(i<listSubMenu.size()-1) jspwriter.write(" | "); } jspwriter.write("</TD></TR></TBODY></TABLE></TD></TR><TR>"); jspwriter.write("<TD bgColor=#cccccc><IMG alt=\"\" border=0 height=3 src=\""+csImgPath+"dot(1).gif\" width=1></TD>"); jspwriter.write("</TR></TBODY></TABLE>"); } private void createLogo() throws Exception { JspWriter jspwriter = pageContext.getOut(); jspwriter.write("<DIV id=point1"); jspwriter.write("style=\"HEIGHT: 50px; POSITION: absolute; WIDTH: 60px; Z-INDEX: 1\">"); jspwriter.write("<A href=\"http://nokia.vip.ccwonline.com.cn/E-order/purchase/dgcar.asp\">"); jspwriter.write("<IMG border=0 src=" + csImgPath + "float.gif></A></DIV>"); jspwriter.write("<TABLE border=0 cellPadding=0 cellSpacing=0 height=70 width=420><TBODY>"); jspwriter.write("<TR><TD align=middle vAlign=bottom><TABLE><TBODY><TR>"); jspwriter.write("<TD>"); jspwriter.write("</TD></TR></TBODY></TABLE></TD>"); jspwriter.write("<TD align=middle class=txt vAlign=bottom width=300><FONT"); jspwriter.write("color=#666666>"+Utility.getMessage("Shop.title")+"</FONT></TD></TR>"); jspwriter.write("<TR><TD align=middle colSpan=2 vAlign=bottom><IMG alt=\"\" border=0 height=5"); jspwriter.write(" src=\""+csImgPath+"dot.gif\" width=1></TD></TR></TBODY></TABLE>"); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -