jsp传值问题如何获取参数问题

  1. 我在一个超连接后加个参数如:
    http://localhost:8080/test/testjstl.jsp?pid=001

    此时在jsp页面中,获取jsp传过来的pid的参数值要使用 ${param.pid}

  1. 如果是在java代码中 ,使用了request.setAttribute(“attr”,”attrValue”);

    那么在jsp中获取request中的参数值就要使用下面的代码 requestScope.attr {attr}

在jsp里面写java代码,js如何取值??

<%@ page import="cn.com.qytx.hotline.util.PropertiesUtil" %>  //需要引啥类就在jsp头部写这个

//设置basePath 
<%
    String ws =PropertiesUtil.getPropertiesValue("application.properties", "seat_clientServer_url");
    String path = request.getContextPath();
    String baseUrl = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort();
    String basePath = baseUrl+path+"/" ;
    request.setAttribute("ctx", basePath);
    request.setAttribute("ws", ws);
    request.setAttribute("baseUrl", baseUrl);
    request.setAttribute("version", "3.1");
    response.setHeader("Cache-Control","no-cache"); //HTTP 1.1    
    response.setHeader("Pragma","no-cache"); //HTTP 1.0    
    response.setDateHeader ("Expires", 0); //prevents caching at the proxy server   
%>

js获取





var basePath = "${ctx}";

你可能感兴趣的:(jsp,java,jsp)