java(Web)ÖÐÏà¶Ô·¾¶£¬¾ø¶Ô·¾¶ÎÊÌâ×ܽá
java(Web)ÖÐÏà¶Ô·¾¶£¬¾ø¶Ô·¾¶ÎÊÌâ×ܽá
Ç°ÑÔ£º
Ç°Ò»¶Îʱ¼ä£¬ÓÉÓÚÔÚ´¦ÀíWebÓ¦ÓÃϵÄÎļþ´´½¨ÓëÒƶ¯µÈ£¬Òò´ËÉæ¼°µ½ºÜ¶à¹ØÓÚjava
ÖÐÏà¶Ô·¾¶£¬¾ø¶Ô·¾¶µÈÎÊÌ⡣ͬʱ£¬¶ÔÓÚWebÓ¦ÓÃÖеÄÏà¶Ô·¾¶£¬¾ø¶Ô·¾¶£¬ÒÔ¼°Java.io.File
ÀàѧϰÁËһϡ£Ò²ÕÒÁËһЩ×ÊÁÏ¡£Ï£Íû´ó¼ÒÓöµ½ÀàËƵÄÎÊÌ⣬¿ÉÒÔ¸üÓÐЧµÄ½â¾ö¡£
=================================================================================
1.»ù±¾¸ÅÄîµÄÀí½â
¡¡¡¡¾ø¶Ô·¾¶£º¾ø¶Ô·¾¶¾ÍÊÇÄãµÄÖ÷Ò³ÉϵÄÎļþ»òĿ¼ÔÚÓ²ÅÌÉÏÕæÕýµÄ·¾¶£¬(URLºÍÎïÀí·¾¶)ÀýÈ磺
C:\xyz\test.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://192.168.0.1/webapp/µÄ¡£
¡¡¡¡ÆäÓõ½µÄµØ·½ÓУº
forward£ºservletÖеÄrequest.getRequestDispatcher(address);Õâ¸öaddressÊÇ
ÔÚ·þÎñÆ÷¶Ë½âÎöµÄ£¬ËùÒÔ£¬ÄãÒªforwardµ½a.jspÓ¦¸ÃÕâôд£º
request.getRequestDispatcher(“/user/a.jsp”)Õâ¸ö/Ïà¶ÔÓÚµ±Ç°µÄwebÓ¦ÓÃwebapp£¬
Æä¾ø¶ÔµØÖ·¾ÍÊÇ£ºhttp://192.168.0.1/webapp/user/a.jsp¡£
sendRedirect£ºÔÚjspÖÐ<%response.sendRedirect("/rtccp/user/a.jsp");%>
2.22¡¢¿Í»§¶ËµÄµØÖ·
ËùÓеÄhtmlÒ³ÃæÖеÄÏà¶ÔµØÖ·¶¼ÊÇÏà¶ÔÓÚ·þÎñÆ÷¸ùĿ¼(http://192.168.0.1/)µÄ£¬
¶ø²»ÊÇ(¸úĿ¼ÏµĸÃWebÓ¦ÓõÄĿ¼)http://192.168.0.1/webapp/µÄ¡£
HtmlÖеÄform±íµ¥µÄactionÊôÐԵĵØÖ·Ó¦¸ÃÊÇÏà¶ÔÓÚ·þÎñÆ÷¸ùĿ¼(http://192.168.0.1/)µÄ£¬
ËùÒÔ£¬Èç¹ûÌá½»µ½a.jspΪ
Ïà¹ØÎĵµ£º
½ñÌìÌ«ÍíÁË £¬µ«ÊÇÀÏʦ²¼ÖõÄ×÷Òµ»¹Ã»ÊÕ¹¦¡£¡£¡£¡£¡£
ÒòΪ×Ô¼ºÇõÃʵÔÚÌ«ÂýÁË£¬ÓÐʱºòÓöµ½¹¤¾ß·¢ÉúÒ»µã´íÎó£¬Ò²ÒªÃÔºý°ë¸öÏûʧ¡£¡£¡£¡£ÎªÊ²Ã´ÊÇÈ«Ó¢Îĵģ¿£¿
»¹ºÃÃ÷ÌìÐÝÏ¢£¬¿ÉÒԺúÃ×öÌâÄ¿£¡
ÒÔÏÂÊDZêÇ©»ù´¡·½ÃæµÄ×ܽᣬÆäʵÎÒ¾õµÃÒªÊDZ³ÏÂÀ´¸üºÃ £¬¹þ¹þ
-->>>¼òµ¥±êÇ©
ʵÏÖSimpleTag½Ó¿ÚµÄ±êǩͨ³£³Æ ......
µÚÒ»½×¶Î£ºJAVA»ù´¡ÔöÇ¿/Oracle+MySqlÊý¾Ý¿â+JDBC¿ª·¢¼¼Êõ+DAO·â×°
ºËÐļ¼Êõ¿Î³Ì
java»ù´¡¼ÓÇ¿£ºÔöÇ¿forÑ»·¡¢¿É±ä²ÎÊý¡¢Ã¶¾Ù¡¢·´Éä¡¢ÄÚÊ¡¡¢beanutils¹¤¾ß¡¢×¢½â¡¢·ºÐÍ¡¢Àà¼ÓÔØ¡¢´úÀí¡¢×°Ïä/²ðÏä¡¢¾²Ì¬ÒýÓõÈJavaм¼ÊõºÍ¸ß¼¶¼¼Êõ¡£
OracleºÍMySqlÊý¾Ý¿â£ºOracleºÍMySqlÊý¾Ý¿â»ù´¡¹ÜÀí¡¢SQL ÓïÑÔ¡¢PL/SQLÓïÑÔ¡¢Êý¾Ý¿âÉ ......
»ª×ÐÔÚÍøÉÏÔĹýÖî¶à¹ØÓÚStringµÄÎÄÕ£¬ÈÔÊÇÓÐÒÉÔÚÐÄÖв»½â£¬ËìÑ°JackÇó»ó¡£
JackµÀ£ººÎ»ó²»½â£¿ÄÃÓëÎÒÃæÇ°±ã¿É¡£
»ª×ÐÊÖÓÚÐÄ£¬È´Äò»³öStringÕâÍæÒâ...JackòÈç´óʦһ̾,½«String³ÊÓÚËûÃæÇ°¡£
“StringÖÐÎÄÃûΪ'×Ö·û´®'£¬Èç´Ë¶øÒÑ£»Éí֮ѪҺ£¬ÄÜÁ¿Ö®ÔØÌå¡£”
1¡¢¼òÊöStringÓëStringBufferµÄÒìͬ¡£
&nb ......
Eclipse Java×¢ÊÍÄ£°åÉèÖÃÏê½â
src url£ºhttp://blog.csdn.net/ahhsxy/archive/2009/09/11/4542682.aspx
ÉèÖÃ×¢ÊÍÄ£°åµÄÈë¿Ú£º Window->Preference->Java->Code Style->Code Template È»ºóÕ¹¿ªComments½Úµã¾ÍÊÇËùÓÐÐèÉèÖÃ×¢Ê͵ÄÔªËØÀ²¡£ÏÖ¾Íÿһ¸öÔªËØÖðÒ»½éÉÜ£º
Îļþ(Files)×¢ÊͱêÇ©£º
/**
......
StringBuilder path = new StringBuilder(request.getScheme());
path.append("://").append(request.getServerName());
path.append(":").append(request.getServerPort()).append(request.getContextPath());
System.out.println("***********path:" + path);
Syste ......