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

java web applicationÖи÷ÖÖ·¾¶µÄÈ¡µÃ·½·¨

¾­³£Íü¼ÇÕâЩ»ù´¡µÄ¶«Î÷£¬¼ÇÏÂÀ´ÁË¡£
ÔÚjspºÍclassÎļþÖе÷ÓõÄÏà¶Ô·¾¶²»Í¬¡£ ÔÚjspÀ¸ùĿ¼ÊÇWebRoot ÔÚclassÎļþÖУ¬¸ùĿ¼ÊÇWebRoot/WEB-INF/classes µ±È»ÄãÒ²¿ÉÒÔÓÃSystem.getProperty("user.dir")»ñÈ¡Ä㹤³ÌµÄ¾ø¶Ô·¾¶¡£
Áí:ÔÚJsp,Servlet,JavaÖÐÏêϸ»ñµÃ·¾¶µÄ·½·¨!
1.jspÖÐÈ¡µÃ·¾¶£º
ÒÔ¹¤³ÌÃûΪTESTΪÀý£º
(1)µÃµ½°üº¬¹¤³ÌÃûµÄµ±Ç°Ò³Ãæȫ·¾¶£ºrequest.getRequestURI()
½á¹û£º/TEST/test.jsp
(2)µÃµ½¹¤³ÌÃû£ºrequest.getContextPath()
½á¹û£º/TEST
(3)µÃµ½µ±Ç°Ò³ÃæËùÔÚĿ¼ÏÂÈ«Ãû³Æ£ºrequest.getServletPath()
½á¹û£ºÈç¹ûÒ³ÃæÔÚjspĿ¼Ï /TEST/jsp/test.jsp
(4)µÃµ½Ò³ÃæËùÔÚ·þÎñÆ÷µÄȫ·¾¶£ºapplication.getRealPath("Ò³Ãæ.jsp")
½á¹û£ºD:\resin\webapps\TEST\test.jsp
(5)µÃµ½Ò³ÃæËùÔÚ·þÎñÆ÷µÄ¾ø¶Ô·¾¶£ºabsPath=new java.io.File(application.getRealPath(request.getRequestURI())).getParent();
½á¹û£ºD:\resin\webapps\TEST
2.ÔÚÀàÖÐÈ¡µÃ·¾¶£º
(1)ÀàµÄ¾ø¶Ô·¾¶£ºClass.class.getClass().getResource("/").getPath()
½á¹û£º/D:/TEST/WebRoot/WEB-INF/classes/pack/
(2)µÃµ½¹¤³ÌµÄ·¾¶£ºSystem.getProperty("user.dir")
½á¹û£ºD:\TEST
3.ÔÚServletÖÐÈ¡µÃ·¾¶£º
(1)µÃµ½¹¤³ÌĿ¼£ºrequest.getSession().getServletContext().getRealPath("") ²ÎÊý¿É¾ßÌåµ½°üÃû¡£
½á¹û£ºE:\Tomcat\webapps\TEST
(2)µÃµ½IEµØÖ·À¸µØÖ·£ºrequest.getRequestURL()
½á¹û£ºhttp://localhost:8080/TEST/test
(3)µÃµ½Ïà¶ÔµØÖ·£ºrequest.getRequestURI()
½á¹û£º/TEST/test


Ïà¹ØÎĵµ£º

Java Éè¼Æ¼Ü¹¹


Ŀ¼
ÕªÒª ……………………………………………………………………2
ÎÄÏ××ÛÊö ……………………&h ......

½âÎöJavaÖеÄFileÀà

File£¨ÎļþÀࣩ
        ¾¡¹Üjava.io¶¨ÒåµÄ´ó¶àÊýÀàÊÇʵÐÐÁ÷ʽ²Ù×÷µÄ£¬FileÀ಻ÊÇ¡£ËüÖ±½Ó´¦ÀíÎļþºÍÎļþϵͳ¡£Ò²¾ÍÊÇ˵£¬FileÀàûÓÐÖ¸¶¨ÐÅÏ¢ÔõÑù´ÓÎļþ¶ÁÈ¡»òÏòÎļþ´æ´¢£»ËüÃèÊöÁËÎļþ±¾ÉíµÄÊôÐÔ¡£File¶ÔÏóÓÃÀ´»ñÈ¡»ò´¦ÀíÓë´ÅÅÌÎļþÏà¹ØµÄÐÅÏ¢£¬ÀýÈçȨÏÞ£¬Ê±¼ä£¬ÈÕÆÚºÍĿ¼·¾¶¡£´ËÍâ ......

¡¶JavaÓëģʽ¡·Ñ¡¶Á¡°Ô­Ê¼Ä£ÐÍ£¨Prototype£©Ä£Ê½¡±

Õâ±¾ÊéÏêϸ½²½âÁËģʽÀíÂÛµÄÓÉÀ´£¨ºÜ¶àÈË¿ÉÄܲ»ÖªµÀģʽÀíÂÛÓëÖйúµÀ¼Ò˼ÏëµÄÔ¨Ô´£©£¬ÃæÏò¶ÔÏóµÄÈí¼þÉè¼ÆÔ­Ôò£¬Ò»Ö±½²µ½¶þÊ®¼¸¸öÉè¼Æģʽ£¬ÒÔ¼°ÕâЩģʽÔÚJavaÓïÑÔÖеÄʵÏֵȵȡ£ÊéÖиø³öÁË´óÁ¿À´×Ô»ª¶û½ÖϵͳµÄÕæʵÏîÄ¿µÄÀý×Ó£¬ÓÃÀ´½²½âÉè¼ÆģʽÔÚϵͳÉè¼ÆÖеÄÓ¦ÓᣠÕâ±¾Êé´¦ÓÚÀíÂÛºÍʵ¼ùÖ®¼ä£¬ÊÇÒ»±¾¶¨Î»¶ÀÌØ¡¢·ç¸ñ¶ÀÌص ......

Java ×Ö·û´®,byte[],16½øÖƵÄ×Ö·û´®»¥×ª

ÔÚµ÷ÊÔµÄʱºò£¬Èç¹ûÒªÏÔʾbyteµÄÖµÊÇ·ñÓëÔ¤ÆÚÒ»Ö£¬Ò»°ãת»»Îª16½øÖƵÄ×Ö·û´®£¬»òÕßʹÓÃbase64ת»»ºó£¬È»ºóÏÔʾ³öÀ´¡£
/**
* ×Ö·û´®×ª»»³ÉÊ®Áù½øÖÆ×Ö·û´®
*/
public static String str2HexStr(String str) {
char[] chars = "0123456789ABCDEF".toCharArray();
StringBuilder sb = new StringBuilder(""); ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ