jsp或用js获得服务器的IP地址
js好像本身不能获取服务器的IP,但JSP可以,所以用个隐藏域,js就可以借鸡下蛋了。
jsp代码如下:
<input type="hidden" id="serviceIp" name="serviceIp" value="<%=InetAddress.getLocalHost().getHostAddress()%>">
js代码如下:
function getServiceIP(){
var serviceIp = document.getElementById("serviceIp").value;
var href ='http://'+serviceIp+':8080/test/';
}
相关文档:
修改了css 样式文件后,重新浏览该jsp页面,发现新修改的样式没有生效。总以为是项目缓存所引起的,于是清理所有项目,重新构建项目。不行。执行server 的 publish 还是不行。用window 的搜索功能发现除了 WebContent 目录有该 css 文件外,.metadata\.plugins\org.eclipse.wst.server.core\tmp1\webapps\ 目录下也存在该 c ......
在jsp中,如果在url中传递中文时会出现乱码,在网上关于这一问题的解决方法五花八门,但都不是很奏效!其实解决方法非常简单: 第一步:编码(以传递的参数为str为例) 在传递数据前将str进行编码Java.net.URLEncoder.encode(str) 第二步:解码 在获取数据端将得到的数据进行解码 new String(str.getBytes("ISO8859_1"))
......
1.request对象
客户端的请求信息被封装在request对象中,通过它才能了解到客户的需求,然后做出响应。它是HttpServletRequest类的实例。
序号 方 法 & ......
错误:
String realPath = " http:// " + request.getServerName() + " : " + request.getServerPort() + request.getContextPath();
String realPath = " http:// " + request.getSer ......