jsp设置

来源:互联网 发布:js。push Array[0] 编辑:程序博客网 时间:2024/06/18 06:36

1.jsp设置全局路径变量


<%    String getContextPath = request.getContextPath();      String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+getContextPath+"/";    out.println("路径:"+basePath);%>




2.页面引用


<script>        var basePath = "<%=basePath%>";                console.log(basePath);        console.log("<%=basePath%>");</script>



3.jsp页面传递参数

url传参:

<a href="b.jsp?name="测试"">点击测试</a>

jsp:


<%    String name=(String)request.getParameter("name");       out.println("路径:"+basePath);%>


0 0