java获取项目所在服务器的ip地址和端口号(获取当前ip地址)
public static String getUrl(){
ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = requestAttributes.getRequest();
String localAddr = request.getLocalAddr();
int serverPort = request.getServerPort();
return "http://"+localAddr +":"+ serverPort;
}