欢迎来到天天文库
浏览记录
ID:1989944
大小:78.00 KB
页数:6页
时间:2017-11-14
《jquery隐藏和显示菜单》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、//使用eclipse新建一个web项目//在web/js目录下添加jquery-1.8.1.min.js (官方下载jquery.js文件)//src目录下的 com.dyg.servlet.CityListServlet类 servlet类提供默认城市列表packagecom.dyg.servlet;importjava.io.IOException;importjava.util.ArrayList;importjava.util.List;importjavax.servlet.ServletException;importjavax.servlet.http.HttpS
2、ervlet;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;publicclassCityListServletextendsHttpServlet{ privatestaticfinallongserialVersionUID=1L; publicCityListServlet(){ super(); } publicvoiddestroy(){ super.destroy();//Justputs"destroy"stringinlog //Put
3、yourcodehere } publicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse) throwsServletException,IOException{ doPost(request,response); } publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse) throwsServletException,IOException{ response.setContentType("text/htm
4、l"); request.setCharacterEncoding("GBK"); response.setCharacterEncoding("GBK"); Listcitys=newArrayList(); citys.add("深圳"); citys.add("北京"); citys.add("上海"); citys.add("武汉"); citys.add("长沙"); citys.add("东莞"); citys.add("佛山"); request.setAttribute("citys",citys); request
5、.getRequestDispatcher("index.jsp").forward(request,response); } publicvoidinit()throwsServletException{ //Putyourcodehere }}//index.jsp web目录下的index.jsp<%@pagelanguage="java"pageEncoding="GBK"%><%@tagliburi="http://java.sun.com/jsp/jstl/core"prefix="c"%>
6、ansitional//EN">
7、tent="Thisismypage"> functionchange2(){ varc=$("a"); if(c.html()=='展开城市列表'){ $('#city').show(); c.
此文档下载收益归作者所有