注意:是客户端的ip,不是获取本机的ip
import javax.servlet.http.*;
import javax.xml.rpc.server.*;
import org.apache.axis.MessageContext;
import org.apache.axis.transport.http.HTTPConstants;
public class BaseService {
public String getClientIp(){
MessageContext mc = MessageContext.getCurrentContext();
HttpServletRequest request = (HttpServletRequest) mc.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
System.out.println("remote ip: " + request.getRemoteAddr());
return request.getRemoteAddr();
}
}
posted on 2006-09-21 14:28
菜籽 阅读(3706)
评论(5) 编辑 收藏 所属分类:
web service