从地址栏获取参数

地址栏:
URL:http://localhost:8888/Test/index.jsp?test=123

1.从地址栏获取参数:
  
<body>
    ${test}
    ${requestScope.test}  
    <%request.getAttribute("test"); %>
</body>
  以上几种办法都获取不到地址栏的参数!!
上边这种方法只有在跳转前的网页写
  request.setAttribute("test","123");
设置request对象的属性时他们才能拿到值
如何获取呢,用下边方法
2.获取地址传参的方法
   <body>
      ${param.test}

    <%=request.getParameter("test") %>
  </body>
用这两种方法均可拿到url中的参数

总结:

${param.name} 请求的参数是表单里的数据或者url的参数
则对应取为 request.getParam("name")


而 request.getAttribute("name")
对应取的EL表达试 为
${requestScope.name};




猜你喜欢

转载自www.cnblogs.com/MrliBlog/p/10980300.html