2015-05-27 45 views

回答

0

這爲我工作:)

import com.ibm.ws.webservices.engine.MessageContext; 
import com.ibm.ws.webservices.engine.transport.http.HTTPConstants; 

.....

HttpServletRequest request = (HttpServletRequest) MessageContext.getCurrentThreadsContext().getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST); 

String clientIpAddress = request.getHeader("X-FORWARDED-FOR"); 

if (clientIpAddress == null) { 
    clientIpAddress = request.getRemoteAddr(); 
} 

System.out.println(clientIpAddress); 
相關問題