使用Ajax怎么实现一个二级联动菜单
本篇文章为大家展示了使用Ajax怎么实现一个二级联动菜单,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。
我们提供的服务有:成都网站设计、网站制作、微信公众号开发、网站优化、网站认证、来安ssl等。为上1000+企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的来安网站制作公司
index.jsp
<%@ page language="java" pageEncoding="UTF-8"%>二级菜单联动演示
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); // 获得请求中参数为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
上述内容就是使用Ajax怎么实现一个二级联动菜单,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注创新互联行业资讯频道。
名称栏目:使用Ajax怎么实现一个二级联动菜单
当前URL:http://ybzwz.com/article/jsccee.html