关于EL表达式中requestScope和param区别
来源:互联网 发布:单片机控制电磁阀 编辑:程序博客网 时间:2024/05/16 07:02
今天演示EL表达式的时候发现自己jsp的基础实在是薄弱,在这个很简单的问题上迷惑了很久。
首先在看遇到的问题:
在浏览器地址输入,表示传入一个参数test,值为123
http://localhost:8888/Test/index.jsp?test=123
在index.jsp中尝试使用EL表达式取出,代码如下:
<body> ${test} </body>
发现毫无结果,再使用requestScope尝试取出:
<body> ${requestScope.test} </body>
发现还是毫无结果,感到非常诧异,遂干脆使用java脚本尝试取出。
<body> <%request.getAttribute("test"); %> </body>
依然无解。
之后发现,若使用已下代码向request作用域赋值,则用上面代码可以取出
<% request.setAttribute("test", "123"); %>
查询资料后发现,使用以下代码可以取出之前的请求参数:
EL:
<body> ${param.test} </body>
JAVA脚本:
<body> <%=request.getParameter("test") %> </body>
结论就是:${param.name} 等价于 request.getParamter("name"),这两种方法一般用于服务器从页面或者客户端获取的内容。
${requestScope.name} 等价于 request.getAttribute("name"),一般是从服务器传递结果到页面,在页面中取出服务器保存的值。
参考资料:
el表达式中的${param}
http://topic.csdn.net/u/20090103/15/779af9b8-c3a7-4f3e-82fe-b08bf2630996.html
原文出自:http://www.cnblogs.com/coolhwm/archive/2011/11/26/2264598.html
0 0
- 关于EL表达式中requestScope和param区别
- 关于EL表达式中requestScope和param区别
- 关于EL表达式中requestScope和param区别
- 关于EL表达式中requestScope和param区别
- 关于EL表达式中requestScope和param区别
- 关于EL表达式中requestScope和param区别
- 关于EL表达式中requestScope和param区别
- 10029---关于EL表达式中requestScope和param区别
- 关于EL表达式中requestScope和param区别
- 关于EL表达式中requestScope和param区别
- 关于EL表达式中requestScope和param区别
- 关于EL表达式中requestScope和param区别
- 关于EL表达式中requestScope和param区别
- 关于EL表达式中requestScope和param区别,el表达式与jstl标签
- 关于EL表达式中requestScope和param区别,el表达式与jstl标签
- EL表达式页面传值(${param}和requestScope)
- J2EE中getParameter与getAttribute以及EL表达式${requestScope}和${param[]}
- J2EE中getParameter与getAttribute以及EL表达式${requestScope}和${param[]}
- MP3 和 ID3
- MPI聚合通信之MPI_Gather函数
- 蓝桥杯——真题训练之打印图形
- ubuntu 12.04 shell 命令下设置代理
- 我的Android心得(8)--Message & Looper & Handler
- 关于EL表达式中requestScope和param区别
- 我这两年的生活工作 2013 2014
- C++中#define用法
- [Linux]使用Mac连接Debian服务器的基础配置
- Android:数据存储
- 我是怎么利用微信月收入三万以上的!(绝对的干货来袭!)
- 设为首页 和 收缩左边栏效果
- FastCgi原理初探
- Ubuntu下解决下载问题