package services;
/**
* Title:
*
* @author yuanzw 创建时间:2010-3-1 下午03:07:14 Description:
* @version
*/
// 注意:是客户端的ip,不是获取本机的ip
import javax.servlet.http.HttpServletRequest;
import org.apache.axis2.context.MessageContext;
import org.apache.axis.transport.http.HTTPConstants;
public class BaseService {
public static String getClientIp() {
MessageContext mc = MessageContext.getCurrentMessageContext();
HttpServletRequest request = (HttpServletRequest) mc
.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
System.out.println("remote ip: " + request.getRemoteAddr());
return request.getRemoteAddr();
}
}
要注意引入的包org.apache.axis2.context.MessageContext
(文/yzw_sy)
来源:http://blog.csdn.net/yzw_sy/article/details/5339803
如果给你带来帮助,欢迎微信或支付宝扫一扫,赞一下。