public class GetIPPort extends ActionSupport{
HttpServletRequest request;
public String getRemortIP(HttpServletRequest request) {
if (request.getHeader("x-forwarded-for") == null) {
return request.getRemoteAddr();
}
return request.getHeader("x-forwarded-for");
}
public void getIp(){
request = ServletActionContext.getRequest();
System.out.println("你的IP为"+getRemortIP(request));
}
}