分類  >  Web前端 >

取得請求IP

tags:    時間:2013-12-09 23:14:48
獲得請求IP

在AbstractInterceptor中

ActionContext ac = invocation.getInvocationContext();  HttpServletRequest request = (HttpServletRequest) ac.get(ServletActionContext.HTTP_REQUEST);  String userRemoteAddr = request.getRemoteAddr(); 

 

HttpServletRequest request = ServletActionContext.getRequest (); 

 

ActionContext ct= ActionContext.getContext();  HttpServletRequest request=(HttpServletRequest)ct.get(ServletActionContext.HTTP_REQUEST);    

 

 在servlet中

String path = request.getContextPath(); String remoteServer = "http://" + request.getServerName(); if (request.getServerPort() != 80) {   remoteServer += ":" + request.getServerPort(); } remoteServer += path;

 

 

推薦閱讀文章

Bookmark the permalink ,來源:互聯網