(ת£ºhttp://blog.csdn.net/alex197963/archive/2008/03/26/2219994.aspx)
1.»ù±¾¸ÅÄîµÄÀí½â
¡¡¡¡¾ø¶Ô·¾¶:¾ø¶Ô·¾¶¾ÍÊÇÄãµÄÖ÷Ò³ÉϵÄÎļþ»òĿ¼ÔÚÓ²ÅÌÉÏÕæÕýµÄ·¾¶,(URLºÍÎïÀí·¾¶)ÀýÈç:
C:xyz est.txt ´ú±íÁËtest.txtÎļþµÄ¾ø¶Ô·¾¶.http://www.sun.com/index.htmÒ²´ú±íÁËÒ»¸ö
URL¾ø¶Ô·¾¶.
¡¡¡¡Ïà¶Ô·¾¶:Ïà¶ÔÓëij¸ö»ù׼Ŀ¼µÄ·¾¶.°üº¬WebµÄÏà¶Ô·¾¶(HTMLÖеÄÏà¶ÔĿ¼),ÀýÈç:ÔÚ
ServletÖÐ,"/"´ú±íWebÓ¦ÓõĸúĿ¼.ºÍÎïÀí·¾¶µÄÏà¶Ô±íʾ.ÀýÈç:"./" ´ú±íµ±Ç°Ä¿Â¼,
"../"´ú±íÉϼ¶Ä¿Â¼.ÕâÖÖÀàËƵıíʾ,Ò²ÊÇÊôÓÚÏà¶Ô·¾¶.
ÁíÍâ¹ØÓÚURI,URL,URNµÈÄÚÈÝ,Çë²Î¿¼RFCÏà¹ØÎĵµ±ê×¼.
RFC 2396: Uniform Resource Identifiers (URI): Generic Syntax,(http://www.ietf.org/rfc/rfc2396.txt)
2.¹ØÓÚJSP/ServletÖеÄÏà¶Ô·¾¶ºÍ¾ø¶Ô·¾¶.
2.1·þÎñÆ÷¶ËµÄµØÖ·
¡¡¡¡ ·þÎñÆ÷¶ËµÄÏà¶ÔµØÖ·Ö¸µÄÊÇÏà¶ÔÓÚÄãµÄwebÓ¦ÓõĵØÖ·,Õâ¸öµØÖ·ÊÇÔÚ·þÎñÆ÷¶Ë½âÎöµÄ
(²»Í¬ÓÚhtmlºÍjavascriptÖеÄÏà¶ÔµØÖ·,ËûÃÇÊÇÓÉ¿Í»§¶Ëä¯ÀÀÆ÷½âÎöµÄ)Ò²¾ÍÊÇ˵Õâʱºò
ÔÚjspºÍservletÖеÄÏà¶ÔµØÖ·Ó¦¸ÃÊÇÏà¶ÔÓÚÄãµÄwebÓ¦ÓÃ,¼´Ïà¶ÔÓÚhttp://localhost/webapp/µÄ.
ÆäÓõ½µÄµØ·½ÓÐ:
forward:servletÖеÄrequest.getRequestDispatcher(address); Õâ¸öaddressÊÇ
ÔÚ·þÎñÆ÷¶Ë½âÎöµÄ,ËùÒÔ,ÄãÒªforwardµ½a.jspÓ¦¸ÃÕâôд:
request.getRequestDispatcher("/user/a.jsp")Õâ¸ö/Ïà¶ÔÓÚµ±Ç°µÄwebÓ¦ÓÃwebapp,
Æä¾ø¶ÔµØÖ·¾ÍÊÇ:http://localhost/webapp/user/a.jsp.
sendRedirect:ÔÚjspÖм´¿ÉÒÔдhttp://localhost/test.jsp Ò²¿ÉÒÔдÏà¶Ô·¾¶µ«URLÏÔʾ·¢ÉúÌøת
2.22,¿Í»§¶ËµÄµØÖ·
ËùÓеÄhtmlÒ³ÃæÖеÄÏà¶ÔµØÖ·¶¼ÊÇÏà¶ÔÓÚ·þÎñÆ÷¸ùĿ¼(http://localhost/)µÄ,
¶ø²»ÊÇ(¸úĿ¼ÏµĸÃWebÓ¦ÓõÄĿ¼)http://localhost/webapp/µÄ.
HtmlÖеÄform±íµ¥µÄactionÊôÐԵĵØÖ·Ó¦¸ÃÊÇÏà¶ÔÓÚ·þÎñÆ÷¸ùĿ¼(http://localhost/)µÄ,
ËùÒÔ,Èç¹ûÌá½»µ½a.jspΪ:action£½"/webapp/user/a.jsp"»òaction="/user/a.jsp;
¡¡¡¡Ìá½»µ½servletΪactiom£½"/webapp/handleservlet"
¡¡¡¡JavascriptÒ²ÊÇÔÚ¿Í»§¶Ë½âÎöµÄ,ËùÒÔÆäÏà¶Ô·¾¶ºÍform±íµ¥Ò»Ñù.
¡¡¡¡Òò´Ë,Ò»°ãÇé¿öÏÂ,ÔÚJSP/HTMLÒ³ÃæµÈÒýÓõÄCSS,Javascript.ActionµÈÊôÐÔÇ°Ãæ×îºÃ¶¼¼ÓÉÏ
,ÒÔÈ·±£ËùÒýÓõÄÎļþ¶¼ÊôÓÚWebÓ¦ÓÃÖеÄĿ¼.
ÁíÍâ,Ó¦¸Ã¾¡Á¿±ÜÃâʹÓÃÀàËÆ".","./","../../"µÈÀàËƵÄÏà¶Ô¸ÃÎļþλÖõÄÏà¶Ô·¾¶,ÕâÑù
µ±ÎļþÒƶ¯Ê±,ºÜÈÝÒ׳öÎÊÌâ.
3. JSP/ServletÖлñµÃ
JavaÁìÓòµÄ¼´Ê±Í¨ÐŵĽâ¾ö·½°¸¿ÉÒÔ¿¼ÂÇopenfire+spark+smack¡£µ±È»Ò²ÓÐÆäËûµÄÑ¡Ôñ¡£
¡¡¡¡OpenfireÊÇ»ùÓÚJabberÐÒé(XMPP)ʵÏֵļ´Ê±Í¨ÐÅ·þÎñÆ÷¶Ë°æ±¾£¬Ä¿Ç°½¨ÒéʹÓÃ3.6.4°æ±¾£¬Õâ¸ö°æ±¾Êǵ±Ç°×îеİ汾£¬¶øÇÒÍøÉÏ¿ÉÒÔÕÒµ½ÏÂÔصÄÔ´´úÂë¡£
¡¡¡¡¼´Ê±Í¨ÐÅ¿Í»§¶Ë¿ÉʹÓÃspark2.5.8,Õâ¸ö°æ±¾ÊÇÄ¿Ç°×îеÄrelease°æ±¾£¬¾¹ý²âÊÔ· ......