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/';
}
相关文档:
上网看了好多,就这一篇解决了我的问题,现转,我的项目用的是MVC架构,有统一的控制器,转向不同的Action,上网看了好多,大部分是说加入request.setCharacterEncoding("utf-8");但是经过我的试验,这只有在利用JSP处理表单传输数据时才可用,在我的东西中无法解决,后来发现还是用FilterChain好,呵呵,重点还是在request ......
找下面写法。
注意,加单引号,第2个百分号之前没有空格,而在jsp中调用的话要空格。
You may be get some help from the code below.
<%
String str="str";
%>
<script>
function accessVar(){
var varStr='<%=str%>';
alert(varStr);// here will diplay ......
1.
<jsp:useBran id="cb" class="bean.CounterBean" >
</jsp:useBean>
对应代码: <%CounterBean cb = new CounterBean();%>
2.
<jsp:setProperty name ="cb" property="count" value = "23"/> 对应代码:
<%-- cb.setCount(Integer.paseInt("23"))- -%>
3.
<jsp:setProperty nam ......
这两天在为项目嵌入这个插件,搞得焦头烂额,成功插入了的,可是不知道什么问题,就是上传不了图片,竟然出现了这样的警告:WARN net.fckeditor.handlers.RequestCycleHandler - No property found for UserPathBuilder implementation! The 'DefaultUserFilesPath' will be used in the ConnectorServlet!
在网上找了半 ......
关于JSP中org.apache.jasper.JasperException:
This absolute uri http://java.sun.com/jsp/jstl/core ) cannot be resolved in either web.xml or the jar files deployed with this application
从网上搜了一下,相同的说法是:一个就是JSTL的版本问题(1.0与1.1),是否不一致 ......