java实现的二级联动菜单效果

网友投稿 282 2023-07-08


java实现的二级联动菜单效果

本文实例讲述了java实现的二级联动菜单效果。分享给大家供大家参考,具体如下:

jsP代码:

<%@ page language="java" pageEncoding="UTF-8"%>

二级联动示例

<!–第一个下拉菜单–>

请选择

北京

天津

山东

<!–第二个下拉菜单–>

请选择

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 = "&lthttp://;select>1昌平";

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 ServleUBCKyIrBLqtException

{

}

}

XML代码:

xmlns:xsi="http://w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee

http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

SelectServlet

com.SelectServlet

SelectServlet

/select

index.jsp

xmlns:xsi="http://w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee

http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

SelectServlet

com.SelectServlet

SelectServlet

/select

index.jsp

更多java相关内容感兴趣的读者可查看本站专题:《Java数据结构与算法教程》、《Java操作DOM节点技巧总结》、《Java文件与目录操作技巧汇总》和《Java缓存操作技巧汇总》

希望本文所述对大家java程序设计有所帮助。


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:JavaWeb监听器Listener实例解析
下一篇:全面了解java byte数组与文件读写
相关文章

 发表评论

暂时没有评论,来抢沙发吧~