Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

jsp¼¸ÖÖ·½·¨

1.±ØÐë¼Ì³Ð×ÔHttpServlet
  2.±ØÐëʵÏÖdoGet()»òÕßdoPost()
  3.±ØÐëÔÚweb.xmlÖÐÅäÖÃServlet
  <servlet>
  <servlet-name> </servlet-name>
  <servlet-class> </servlet-class>
  </servlet>
  <servlet-mapping>
  <servlet-name> </servlet-name>
  <url-pattern> </url-pattern>
  </servelt-mapping>
  
  HttpServeltRrequest:ÇëÇó¶ÔÏó
  getParameter():»ñµÃ±íµ¥ÔªËصÄÖµ
  getAttribute():»ñµÃrequest·¶Î§ÖеÄÊôÐÔÖµ
  setAttribute():ÉèÖÃreqeust·¶Î§ÖеÄÊôÐÔÖµ
  setCharacterEncoding():ÉèÖÃ×Ö·û±àÂë
  
  HttpSerletResponse:ÏàÓ¦¶ÔÏó
  sendRedirect():ÍⲿÌøת
  getWriter():»ñµÃÊä³öÁ÷¶ÔÏó
  setContentType("text/html; charset=utf-8"):ÉèÖÃÏàÓ¦ÄÚÈݸñʽºÍ±àÂë
  
  ËÄÖֻỰ¸ú×Ù·½Ê½:
  1.Session
  HttpSession session = request.getSession();
  session.setAttribute("name", "zhangsan");
  session.setAttribute("pwd", "aaa");
  String name = (String) session.getAttribute("name");
  
  2.cookie:
  //´´½¨Cookie
  Cookie cookie = new Cookie("name", "zhangsan");
  //ÉèÖÃCookieµÄ³¬Ê±Ê±¼ä
  cookie.setMaxAge(24 * 60 * 60 *60);
  //°ÑCookie·¢Ë͵½¿Í»§¶Ë
  response.addCookie(cookie);
  
  //µÃµ½¿Í»§¶Ë·¢Ë͵ÄCookie
  Cookie [] cookies = request.getCookies();
  for(int i=0; i <cookies.length; i++) {
   Cookie temp = cookies[i];
   String key = temp.getName();
   String value = temp.getValue();
  }
  
  3.Òþ²Ø±íµ¥Óò
  <input type="hidden" name="name" value="zhangsan" />
  request.getParameter("name");
  
  4.UrlÖØд
  ÎʺŴ«²Î
  LoginServlet?username=zhangsan&pwd=123
  String name = request.getParameter("username");
 


Ïà¹ØÎĵµ£º

JspÉú³É¾²Ì¬Ò³Ãæ

ΪÁ˼õÇá·þÎñÆ÷ѹÁ¦£¬½«Ô­À´µÄÎÄÕ¹ÜÀíϵͳÓÉJSPÎļþµÄ´ÓÊý¾Ý¿âÖÐÈ¡Êý¾ÝÏÔʾ¸ÄΪÓÉjspÉú³É¾²Ì¬htmlÎļþºóÖ±½Ó·ÃÎÊhtmlÎļþ¡£Ê×ÏÈÓ¦´´½¨Ò»¸öÄ£°åÎļþ£¬ÎļþÃûºÍÎļþºó׺¿ÉÒÔËæÒ⣬µ«ÎÒÒ»°ã³£ÓõĻ¹ÊÇ *.template £¬Òò´Ë£¬ÕâÀï¾ÍÒÔ template.template ΪÀý( ½«Ä£°åÎļþ·ÅÈë /WEB-INF/templates/ Îļþ¼ÐÏ )£ºÏÂÃæÊÇÒ»¸ö¼òµ¥µÄ ......

jsp×Ô¶¨Òå±êÇ©¿ª·¢

²»´¦ÀíÌåÄÚÈݵıêÇ©Àí½âÒ»ÏÂͼƬ1
´¦ÀíÌåÄÚÈݱêÇ©Àí½âÌáͼƬ2
1£ºJspWriter out = pageContext.getOut();
2£ºBodyContent bc = this.getBodyContent();
 3£ºString input = bc.getString();
 4£ºJspWriter out = bc.getEnclosingWriter();
²»´¦ÀíÌåÄÚÈÝ
µÚÒ»ÐдúÂëΪ²»´¦Àí±êÇ©ÌåÄÚÈÝʱÄõ½ÐèÒªµÄÊä³öµ½Ò³ ......

ÌáÉýJSPÓ¦ÓóÌÐòµÄÆß´ó¾øÕÐ


Äãʱ³£±»¿Í»§±§Ô¹JSPÒ³ÃæÏìÓ¦ËٶȺÜÂýÂð£¿ÄãÏë¹ýµ±¿Í»§·ÃÎÊ´ÎÊý¾çÔöʱ£¬ÄãµÄWEBÓ¦ÓÃÄܳÐÊÜÈÕÒæÔö¼ÓµÄ·ÃÎÊÁ¿Âð£¿
      ±¾ÎĽ²ÊöÁ˵÷ÕûJSPºÍservletµÄһЩ·Ç³£ÊµÓõķ½·¨£¬Ëü¿ÉʹÄãµÄservletºÍJSPÒ³ÃæÏìÓ¦¸ü¿ì£¬À©Õ¹ÐÔ¸üÇ¿¡£¶øÇÒÔÚÓû§ÊýÔö¼ÓµÄÇé¿öÏ£¬ÏµÍ³¸ºÔØ»á³ÊÏÖ³öƽ»¬Éϳ¤µÄÇ÷ÊÆ¡£ÔÚ±¾ÎÄÖ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ