Java Web µÚËÄÌì ʹÓÃServlet´¦ÀíÇëÇó
Ò»¡¢
GET
ºÍ
POST
µÄÇø±ð
1.GET
Ìá½»µÄÊÇÎı¾ÄÚÈÝ£¬¹æ¶¨ÆäÊý¾Ý³¤¶È²»³¬¹ý
255
¸ö×Ö·û¡£ÔÚ
GET
·½Ê½Ìá½»µÄ
URL
ÖлáÏÔʾ³öÌá½»µÄ²éѯÊý¾Ý¶øÈ´Ìá½»Êý¾ÝµÄ»º´æ»áÔÚä¯ÀÀÆ÷µÄ
URL
Àúʷ״̬ÖУ¬ÕâÑùÎÒÃÇÍùÍùÔÚä¯ÀÀÍøÒ³µÄʱºòµã»÷ºóÍ˼ü²»ÐèÒªÖØз¢ËÍÇëÇó¡£
2.POST
Ìá½»µÄ¿ÉÒÔʹÎı¾ÄÚÈÝ£¬Ò²¿ÉÒÔʹ¶þ½øÖÆÄÚÈÝ£¬ËùÒÔÎÒÃÇÉÏ´«ÎļþµÄʱºòÓõľÍÊÇ
POST
µÃ·½Ê½¡£
POST
¶ÔÓÚÌá½»Êý¾Ý³¤¶ÈûÓÐÏÞÖÆ£¬ÎÒÃÇ·¢Ë͵ÄÊý¾ÝÒ²²»»áÔÚ
URL
ÖгöÏÖ£¬ËùÒÔÕâÖÖ·½Ê½½ÏΪ°²È«¡£µ«ÊÇÍøÒ³Ìá½»µÄÊý¾Ý»º´æ²»»áÔÚä¯ÀÀÆ÷ÖдæÔÚ£¬ËùÒÔÎÒÃǵã»÷ºóÍ˵½´ËÀàµÄÍøÒ³µÄʱºòÒ»°ã»á³öÏÖÊý¾Ý¹ýÆÚµÈÌáʾ¡£
3
£®Ìá½»Êý¾ÝµÄʱºòÒ»°ãÖ»ÓÐ±íµ¥²ÅÓÃ
POST
µÄÐÎʽ£¬ÆäËûµÄ¶¼ÊÇ
GET
µÄ·½Ê½¡£
¶þ¡¢
HTTP
ÇëÇó·½·¨Óë
HttpServlet
·½·¨µÄ¶ÔÓ¦¹Øϵ
1.
ÈÝÆ÷µ÷ÓÃ
service
£¨
ServletRequest ,ServletResponse
£©·½·¨£»
2. service
£¨
ServletRequest ,ServletResponse
£©·½·¨ÔÙµ÷ÓÃͬһ¸ö
Servlet
ÀàÖеÄ
service
£¨
HttpServletRequest ,HttpServletResponse
£©·½·¨£»
3. service
£¨
HttpServletRequest ,HttpServletResponse
£©½«·ÖÎö
HTTP
ÇëÇó£¬ÕÒµ½ÇëÇó·½·¨ÀàÐÍÈ»ºóµ÷ÓÃÏàÓ¦µÄ´¦Àí·½·¨¡£
4.
Èç¹ûÔÚ×Ô¶¨ÒåµÄ
Servlet
ÀàÖи²¸Ç
service
·½·¨£¬
do
×××·½·¨½«²»»á×Ô¶¯µ÷Óá£
Èý¡¢
HTTP
ÇëÇóÐеĻñÈ¡
getMothod()
£º»ñµÃÇëÇóÌá½»·½Ê½
getRequestURI
£¨£©£º»ñÈ¡Ìá½»µÄ
URI
getServletPath()
£º»ñÈ¡
Servlet
Ó³Éä·¾¶¡£
ËÄ¡¢
HTTP
ÇëÇóÍ·µÄ»ñµÃ
Enumeration eu = request.getHeaderName();
while(eu.hasMoreElements()){
String name = (String)en.nextElements();
String values = (String)en.getHeader(name);
}
Îå¡¢
HTTP
ÏûÏ¢ÌåµÄ»ñÈ¡
ÀûÓÃ
getParameter(String name)
¿É»ñµÃÌá½»±íµ¥µÄÄÚÈÝ£¬µ«¸Ã·½·¨Ö»ÊÊÓÃÓÚÎı¾ÎļþµÄ»ñµÃ£¬²»ÄÜ»ñÈ¡¶þ½øÖƵÄÊý¾Ý¡£
Áù¡¢ÎļþÉÏ´«
1.
ÉèÖÃ±íµ¥Ìá½»Êý¾Ý·½Ê½Îª
POS
Ïà¹ØÎĵµ£º
ÒÔÏÂÖ»ÊǸöÈËÀí½â
½ñÌìѧϰspringÖеÄÊôÐÔ×¢È룬ÔÚ½²ÔÀíµÄʱºò£¬Ìáµ½ÁËjavaÖеÄÄÚÄÚÊ¡»úÖÆ£¬ÔÚÒÔÇ°Ö»ÊÇÁ˽âһϷ´Éä»úÖÆ¡£
·´Éä»úÖÆÊÇjavaÖеĶ¯Ì¬ÐÔÄÜ£¬¿ÉÒÔÒÔÀàÃûµÃµ½Àà¶ÔÏóµÄ¼¼Êõ£¬ÊµÏÖ¶¯Ì¬Éú³É¶ÔÏó¼¼Êõ£¬¿ÉÒÔÒÔ¶ÔÏóµÃµ½´Ë¶ÔÏóµÄÀàÐÅÏ¢£¨°üÀ¨ÊôÐÔ£¬·½·¨£©£¬ÊµÏִ˼¼ÊõµÄÊÇjavaÖеÄClass¶ÔÏ󣬴˶ÔÏóÊÇÃè ......
7£®1 Swing¼ò½é
7.1.1 ¼ò½é
¡¡¡¡µÚÎå½²ÖÐÎÒÃÇѧϰÁËAWT£¬AWTÊÇSwingµÄ»ù´¡¡£SwingµÄ²úÉúÖ÷ÒªÔÒò¾ÍÊÇAWT²»ÄÜÂú×ãͼÐλ¯Óû§½çÃæ·¢Õ¹µÄÐèÒª¡£
AWTÉè¼ÆµÄ³õÖÔÊÇÖ§³Ö¿ª·¢Ð¡Ó¦ÓóÌÐòµÄ¼òµ¥Óû§½çÃæ¡£ÀýÈçAWTȱÉÙ¼ôÌù°å¡¢´òÓ¡Ö§³Ö¡¢¼üÅ̵¼º½µÈÌØÐÔ£¬¶øÇÒÔÀ´µÄAWTÉõÖÁ²»°üÀ¨µ¯³öʽ²Ëµ¥»ò¹ö¶¯´°¸ñµÈ»ù±¾ÔªËØ¡£
¡¡¡¡´ËÍâAWT»¹´ ......
ΪÁ˽øÐзÇ×èÈûµÄsocketͨÐÅ£¬java nioÌṩChannel¸ÅÄîµÄʵÏÖ¡£Channel¸ÅÄîÒÔÇø±ðÓÚ´«Í³µÄ»ùÓÚÁ÷¸ÅÄîµÄIO¡£ÊÂʵÉÏChannel¸ÅÄîµÄIO¼È°üÀ¨·Ç×èÈûʽµÄIOÒ²°üÀ¨×èÈûʽIO¡£ÒªChannelÍê³É·Ç×èÈûʽIOÐèҪʵÏÖSelectableChannel½Ó¿Ú£¬ÓëSelector¹ØÁªÊ¹Óá£SocketChannel¾ÍÊÇÕâÑùÒ»¸öSelectableChannel¡£
ÓÉÓÚ£¬selector»úÖƱ¾ÉíÉ ......
Ò»¡¢
ΪʲôҪʹÓÃ
JSP
ÔÚ¿Í»§¶ËÍøÒ³±à³ÌÖÐ
Java
µÄ½â¾ö·½°¸ÊÇ
Servlet/JSP
¡£¶ÔÓÚ¶¯Ì¬Ò³ÃæµÄÐγÉÎÒÃÇ¿ÉÒÔÀûÓÃÔÚ
Servlet
Öбàд×Ö·û´®ÊµÏÖ£¬µ«ÊÇÕâÑù»áʹ³ÌÐòÔ±µÄ¹¤×÷±äµÃÒì³£µÄ·±Ëö£¬ËùÒÔÎÒÃDzÉÓÃ
JSP
´ïµ½ÍøÒ³µÄ¶¯Ì¬ÏÔʾ¡£
¶þ¡¢
ʲôÊÇ
JSP
JSP
£¨
JavaServerPage
£©ºÍ
Servlet
ÊÇ
Java
ÖвúÉú¶¯Ì ......
java.lang.Object ÌṩÁËÒ»¸ötoString()µÄ·½·¨£¬µ«Êµ¼ÊÉÏÕâ¸ö·½·¨·µ»ØµÄÍùÍù²»ÊÇÎÒÃÇÐèÒªµÄ£¬Ëü·µ»ØµÄÊÇÀàÃû¼ÓÉÏ“@”¼ÓÉÏÊ®Áù½øÖƵÄhashÖµ¡£ÕâÏÔÈ»²»ÊÇÎÒÃÇÏëÒªµÄ£¬ËùÒÔ±ØÐëÖØÔØtoStringº¯Êý¡£
ºÜ¼òµ¥µÄÀý×Ó£¬ÈçÏÂ
System.out.println("Failed to connect: " + phoneNumber);
Èç¹û²»ÖØÔØ£¬ÔòÓÐ
Failed to co ......