动态获取项目地址ip变localhost问题

ServletActionContext.getRequest().getScheme()   //协议 如http
   + "://"
   + ServletActionContext .getRequest().getLocalAddr()  //ip地址
/*+ ServletActionContext.getRequest().getServerName()*/
+ ":"

+ ServletActionContext.getRequest().getServerPort()  //端口号


getLocalAddr遇到localhost会自动变为127.0.0.1,遇到ip形式的就为ip

getServerName可能会把ip变为localhost

 

(getLocalAddr 遇到ip变为127.0.0.1,外网地址变为内网地址

 getServerName 遇到ip就为ip 20140410)

 


你可能感兴趣的:(动态获取项目地址ip变localhost问题)