HttpServletRequest.getLocalAddr()问题。 HttpServletRequest.getLocalAddr(),得到的ip是0.0.0.0 是怎么回事呀? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public String getUrl() { HttpServletRequest req = FlexContext.getHttpRequest(); String serverIp = req.getLocalAddr(); int serverPort = req.getLocalPort(); String webAppName = FlexContext.getHttpRequest().getContextPath(); StringBuffer bufPath = new StringBuffer();// bufPath.append("http://");// bufPath.append(serverIp); String urlIp = req.getRequestURL().toString(); int weiz = urlIp.lastIndexOf(":"); urlIp = urlIp.substring(0, weiz); bufPath.append(urlIp); if (serverPort != 80) bufPath.append(":" + serverPort); bufPath.append(webAppName); return bufPath.toString(); } InetAddress address = InetAddress.getLocalHost();address.getHostAddress();试试 系统host文件设置localhost为127.0.0.1就好了 你换这个方法:request.getRemoteAddr();试试。 hibernate插入报错。。。求解答! 监听电脑键盘按下哪个键,最好是java的 如何在java类中设置session中的值 本年最后一天,元旦快乐!散分!!!!¥200 Get请求问题 ireport导出excel hibernate中的SessionFactory,Session分别表示什么啊?如何理解? tomcat的怪问题。。。。 (在线等) 关于Servlet映射 PreparedStatement 设置好参数以后怎么把SQL打出来呀!!!! 在生成xml的时候,如果出现连续两个标签怎么让这两个标签在同一行。 如何让IE一打开就全屏显示,按F11那种
HttpServletRequest req = FlexContext.getHttpRequest();
String serverIp = req.getLocalAddr();
int serverPort = req.getLocalPort();
String webAppName = FlexContext.getHttpRequest().getContextPath();
StringBuffer bufPath = new StringBuffer();
// bufPath.append("http://");
// bufPath.append(serverIp);
String urlIp = req.getRequestURL().toString();
int weiz = urlIp.lastIndexOf(":");
urlIp = urlIp.substring(0, weiz);
bufPath.append(urlIp);
if (serverPort != 80)
bufPath.append(":" + serverPort);
bufPath.append(webAppName);
return bufPath.toString();
}
address.getHostAddress();
试试