本篇文章為大家展示了使用Ajax怎么實(shí)現(xiàn)一個(gè)二級(jí)聯(lián)動(dòng)菜單,內(nèi)容簡明扼要并且容易理解,絕對(duì)能使你眼前一亮,通過這篇文章的詳細(xì)介紹希望你能有所收獲。
我們提供的服務(wù)有:成都網(wǎng)站設(shè)計(jì)、網(wǎng)站制作、微信公眾號(hào)開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、來安ssl等。為上1000+企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的來安網(wǎng)站制作公司
index.jsp
<%@ page language="java" pageEncoding="UTF-8"%>二級(jí)菜單聯(lián)動(dòng)演示
SelectServlet.java
package com; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /*** * * @author zdw * */ public class SelectServlet extends HttpServlet { private static final long serialVersionUID = 1L; public SelectServlet() { super(); } public void destroy() { super.destroy(); } public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // response.setCharacterEncoding("GBK"); response.setContentType("text/xml"); response.setHeader("Cache-Control", "no-cache"); request.setCharacterEncoding("GBK"); response.setCharacterEncoding("UTF-8"); String targetId = request.getParameter("id").toString(); System.out.println(targetId); // 獲得請(qǐng)求中參數(shù)為id的值 String xml_start = ""; String xml_end = " "; String xml = ""; if (targetId.equalsIgnoreCase("0")) { xml = ""; } else if (targetId.equalsIgnoreCase("1")) { xml = ""; xml += ""; xml += ""; xml += ""; } else if (targetId.equalsIgnoreCase("2")) { xml = ""; xml += ""; xml += ""; xml += ""; } else {// 如果是3,則返回下面的字符 xml = ""; xml += ""; xml += ""; xml += ""; } String last_xml = xml_start + xml + xml_end; response.getWriter().write(last_xml); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } public void init() throws ServletException { } }
web.xml
SelectServlet com.SelectServlet SelectServlet /select index.jsp
上述內(nèi)容就是使用Ajax怎么實(shí)現(xiàn)一個(gè)二級(jí)聯(lián)動(dòng)菜單,你們學(xué)到知識(shí)或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識(shí)儲(chǔ)備,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。