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

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Ϊ


Ïà¹ØÎĵµ£º

Ò»¸öJava³ÌÐòÔ±Ó¦¸ÃÕÆÎÕµÄ10Ïî¼¼ÄÜ

1¡¢Óï·¨£º±ØÐë±È½ÏÊìϤ£¬ÔÚд´úÂëµÄʱºòIDEµÄ±à¼­Æ÷¶ÔijһÐб¨´íÓ¦¸ÃÄܹ»¸ù¾Ý±¨´íÐÅÏ¢ÖªµÀÊÇʲôÑùµÄÓï·¨´íÎó²¢ÇÒÖªµÀÈκÎÐÞÕý¡£
2¡¢ÃüÁ±ØÐëÊìϤJDK´øµÄһЩ³£ÓÃÃüÁî¼°Æä³£ÓÃÑ¡ÏÃüÁîÖÁÉÙÐèÒªÊìϤ£ºappletviewer¡¢ HtmlConverter¡¢jar¡¢ java¡¢javac¡¢javadoc¡¢javap¡¢javaw¡¢native2ascii¡¢serialver£¬Èç¹ûÕâЩÃüÁî ......

ðÅÝÅÅÐò£¨Ã JAVA°æ

public void sort(int[] array) {
  for(int i=0; i<array.length; i++) {
    boolean flag = true;
    for(int j=0; j<array.length-i-1; j++) {
      if(array[j]>array[j+1]) {
        int tmp = ar ......

java ±àÂë´¦Àí¹ý³Ì ÒýÓÃ

ÕâÊÇһƪ¹ØÓÚ±àÂëµÄÎÄÕÂдµÄºÜºÃ!
   ÊÀ½çÉϵĸ÷µØÇø¶¼Óб¾µØµÄÓïÑÔ¡£µØÇø²îÒìÖ±½Óµ¼ÖÂÁËÓïÑÔ»·¾³µÄ²îÒì¡£ÔÚ¿ª·¢Ò»¸ö¹ú¼Ê»¯³ÌÐòµÄ¹ý³ÌÖУ¬´¦ÀíÓïÑÔÎÊÌâ¾ÍÏԵúÜÖØÒªÁË¡£
¡¡¡¡ÕâÊÇÒ»¸öÊÀ½ç·¶Î§ÄÚ¶¼´æÔÚµÄÎÊÌ⣬ËùÒÔ£¬JavaÌṩÁËÊÀ½çÐԵĽâ¾ö·½·¨¡£±¾ÎÄÃèÊöµÄ·½·¨ÊÇÓÃÓÚ´¦ÀíÖÐÎĵģ¬µ«ÊÇ£¬Íƶø¹ãÖ®£¬¶ÔÓÚ´¦À ......

java action ·¾¶ÎÊÌâ

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 ......

Java String.Format() ·½·¨¼°²ÎÊý˵Ã÷

JDK1.5ÖУ¬StringÀàÐÂÔöÁËÒ»¸öºÜÓÐÓõľ²Ì¬·½·¨String.format():
format(Locale l, String format, Object... args) ʹÓÃÖ¸¶¨µÄÓïÑÔ»·¾³¡¢¸ñʽ×Ö·û´®ºÍ²ÎÊý·µ»ØÒ»¸ö¸ñʽ»¯×Ö·û´®¡£
format(String format, Object... args) ʹÓÃÖ¸¶¨µÄ¸ñʽ×Ö·û´®ºÍ²ÎÊý·µ»ØÒ»¸ö¸ñʽ»¯×Ö·û´®¡£
¾Ù¼¸¸öÕâ¸ö·½·¨ÊµÓõÄÀý×Ó(×¢ÊÍÊÇÊä³ö½á¹û)£º ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ