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

Java»ñÈ¡¿Í»§¶ËÕæÊµIPµØÖ·µÄÁ½ÖÖ·½·¨

ÔÚJSPÀ»ñÈ¡¿Í»§¶ËµÄIPµØÖ·µÄ·½·¨ÊÇ£ºrequest.getRemoteAddr£¨£©£¬ÕâÖÖ·½·¨Ôڴ󲿷ÖÇé¿ö϶¼ÊÇÓÐЧµÄ¡£µ«ÊÇÔÚͨ¹ýÁËApache£¬SquidµÈ·´Ïò´úÀíÈí¼þ¾Í²»ÄÜ»ñÈ¡µ½¿Í»§¶ËµÄÕæÊµIPµØÖ·ÁË¡£
¡¡¡¡
Tag£ºJava ¿Í»§¶Ë ÕæÊµIPµØÖ·
ÔÚJSPÀ»ñÈ¡¿Í»§¶ËµÄIPµØÖ·µÄ·½·¨ÊÇ£ºrequest.getRemoteAddr£¨£©£¬ÕâÖÖ·½·¨Ôڴ󲿷ÖÇé¿ö϶¼ÊÇÓÐЧµÄ¡£µ«ÊÇÔÚͨ¹ýÁËApache£¬SquidµÈ·´Ïò´úÀíÈí¼þ¾Í²»ÄÜ»ñÈ¡µ½¿Í»§¶ËµÄÕæÊµIPµØÖ·ÁË¡£
Èç¹ûʹÓÃÁË·´Ïò´úÀíÈí¼þ£¬½«http://192.168.1.110£º2046/ µÄURL·´Ïò´úÀíΪ http://www.javapeixun.com.cn / µÄURLʱ£¬ÓÃrequest.getRemoteAddr£¨£©·½·¨»ñÈ¡µÄIPµØÖ·ÊÇ£º127.0.0.1¡¡»ò¡¡192.168.1.110£¬¶ø²¢²»Êǿͻ§¶ËµÄÕæÊµIP¡£
¾­¹ý´úÀíÒÔºó£¬ÓÉÓÚÔÚ¿Í»§¶ËºÍ·þÎñÖ®¼äÔö¼ÓÁËÖмä²ã£¬Òò´Ë·þÎñÆ÷ÎÞ·¨Ö±½ÓÄõ½¿Í»§¶ËµÄIP£¬·þÎñÆ÷¶ËÓ¦ÓÃÒ²ÎÞ·¨Ö±½Óͨ¹ýת·¢ÇëÇóµÄµØÖ··µ»Ø¸ø¿Í»§¶Ë¡£µ«ÊÇÔÚת·¢ÇëÇóµÄHTTPÍ·ÐÅÏ¢ÖУ¬Ôö¼ÓÁËX£­FORWARDED£­FORÐÅÏ¢¡£ÓÃÒÔ¸ú×ÙÔ­ÓеĿͻ§¶ËIPµØÖ·ºÍÔ­À´¿Í»§¶ËÇëÇóµÄ·þÎñÆ÷µØÖ·¡£µ±ÎÒÃÇ·ÃÎÊhttp://www.javapeixun.com.cn /index.jsp/ ʱ£¬Æäʵ²¢²»ÊÇÎÒÃÇä¯ÀÀÆ÷ÕæÕý·ÃÎʵ½ÁË·þÎñÆ÷ÉϵÄindex.jspÎļþ£¬¶øÊÇÏÈÓÉ´úÀí·þÎñÆ÷È¥·ÃÎÊhttp://192.168.1.110£º2046/index.jsp £¬´úÀí·þÎñÆ÷ÔÙ½«·ÃÎʵ½µÄ½á¹û·µ»Ø¸øÎÒÃǵÄä¯ÀÀÆ÷£¬ÒòΪÊÇ´úÀí·þÎñÆ÷È¥·ÃÎÊindex.jspµÄ£¬ËùÒÔindex.jspÖÐͨ¹ýrequest.getRemoteAddr£¨£©µÄ·½·¨»ñÈ¡µÄIPʵ¼ÊÉÏÊÇ´úÀí·þÎñÆ÷µÄµØÖ·£¬²¢²»Êǿͻ§¶ËµÄIPµØÖ·¡£
ÓÚÊǿɵóö»ñµÃ¿Í»§¶ËÕæÊµIPµØÖ·µÄ·½·¨Ò»£º
public String getRemortIP(HttpServletRequest request) {
if (request.getHeader("x-forwarded-for") == null) {
return request.getRemoteAddr();
}
return request.getHeader("x-forwarded-for");
}
¿ÉÊǵ±ÎÒ·ÃÎÊhttp://www.5a520.cn /index.jsp/ ʱ£¬·µ»ØµÄIPµØÖ·Ê¼ÖÕÊÇunknown£¬Ò²²¢²»ÊÇÈçÉÏËùʾµÄ127.0.0.1¡¡»ò¡¡192.168.1.110ÁË£¬¶øÎÒ·ÃÎÊhttp://192.168.1.110£º2046/index.jsp ʱ£¬ÔòÄÜ·µ»Ø¿Í»§¶ËµÄÕæÊµIPµØÖ·£¬Ð´Á˸ö·½·¨È¥ÑéÖ¤¡£Ô­Òò³öÔÚÁËSquidÉÏ¡£squid.conf µÄÅäÖÆÎļþ¡¡forwarded_for ÏîĬÈÏÊÇΪon£¬Èç¹û forwarded_for Éè³ÉÁË off ¡¡Ôò£ºX-Forwarded-For£º unknown
ÓÚÊǿɵóö»ñµÃ¿Í»§¶ËÕæÊµIPµØÖ·µÄ·½·¨¶þ£º
public String getIpAddr(HttpServletRequest request) {
String ip = request.getHeader("x-forwarded-for");


Ïà¹ØÎĵµ£º

linuxÅäÖÃjava»·¾³±äÁ¿(Ïêϸ)

ÏÖÔÚÓÃlinuxµÄÅóÓÑÔ½À´Ô½¶àÁË£¬Ç°¼¸Ìì¾ÍÓÐÁ½¸öÅóÓÑÎÊÎÒlinuxÏÂÔõôÅäÖÃjava»·¾³£¬ÎÒÏ뻹ÓкܶàÅóÓÑÏëÁ˽âѧϰÕâ·½ÃæµÄ¶«Î÷£¬¾Íдһ¸öÍêȫһµãµÄlinux java»·¾³ÅäÖðɣ¬Ï£Íû¶Ô´ó¼ÒÓаïÖú¡£
Ò». ÏÂÔØjdk5.0 for linux
¡¡¡¡µ½sunµÄÖ÷Ò³ http://java.sun.com/j2se/1.5.0/download.jsp ÏÂÔØjdk°²×°Îļþjdk-1_5_0_05-linux-i586 ......

java·½·¨´«ÖµºÍ´«ÒýÓÃ

ij֪ÃûÃÅ»§ÍøÕ¾µÄÒ»µÀ±ÊÊÔÌâ
public class Test {
public static void stringUpd(String str) {
str = str.replace("j", "l");
System.out.println(str);
}

public static void stringBufferUpd(StringBuffer bf) {
bf.append("c");
System.out.println(bf);
}

......

java ÃæÊÔÌâ

Java
»ù´¡·½Ãæ
:
1
¡¢
char
ÐͱäÁ¿ÖÐÄܲ»ÄÜ´æÖüÒ»¸öÖÐÎĺº×Ö
?
Ϊʲô
?
´ð£º
ÊÇÄܹ»¶¨Òå³ÉΪһ¸öÖÐÎĵģ¬ÒòΪjavaÖÐÒÔunicode±àÂ룬һ¸öcharÕ¼16×Ö½Ú£¬ËùÒÔ·ÅÒ»¸öÖÐÎÄÊÇûÎÊÌâµÄ
2:
À¬»ø»ØÊÕ»úÖÆ
,
ÈçºÎÓÅ»¯³ÌÐò

A:javaÖеÄÀ¬»øÊÕ¼¯
£¨Garbage Collection,GC£©ÓÃÀ´»ØÊÕÄÇЩ¹ýÈ¥·ÖÅäµÄ²»ÔÙÓ ......

JAVA¶ÁÈ¡iniÎļþµÄÒ»¸öÀ࣬´æ×ÅÒÔ±¸ºóÓã¡

package com.qiao.java;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Iter ......

javaÆðÔ´

¡¡Javaƽ̨ÓÉJavaÐéÄâ»ú£¨Java Virtual Machine£©ºÍJava Ó¦Óñà³Ì½Ó¿Ú£¨Application Programming Interface¡¢¼ò³ÆAPI£©¹¹³É¡£Java Ó¦Óñà³Ì½Ó¿ÚΪJavaÓ¦ÓÃÌṩÁËÒ»¸ö¶ÀÁ¢ÓÚ²Ù×÷ϵͳµÄ±ê×¼½Ó¿Ú£¬¿É·ÖΪ»ù±¾²¿·ÖºÍÀ©Õ¹²¿·Ö¡£ÔÚÓ²¼þ»ò²Ù×÷ϵͳƽ̨Éϰ²×°Ò»¸öJavaƽ̨֮ºó£¬JavaÓ¦ÓóÌÐò¾Í¿ÉÔËÐС£ÏÖÔÚJavaƽ̨ÒѾ­Ç¶ÈëÁ˼¸ºõËù ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ