J2EE中getParameter与getAttribute以及EL表达式${requestScope}和${param[]}

简介:

getParameter

① 得到的都是String类型的。如http://name.jsp?name=xy中的xy

② 获取POST/GET传递的参数值

③ 用于客户端重定向,如点击链接或提交按扭时,即用于在用表单或url重定向传值时接收数据用

 


getAttribute

① 获取的类型是Object

② 用于服务器端重定向,即在sevlet中使用forward函数或struts中getter/setter属性。getAttribute只能收到程序用setAttribute传来的值

③ session.getAttribute()可获得session

 


EL表达式

使用表达式语言可以直接获取请求参数值,可以获取页面中JavaBean的指定属性值,获取请求头以及获取page,request,session和application。

EL表达式有11个内置对象

pageContext
pageScope
requestScope
sessionScope
applicationScope
param
paramValues
header
headerValues
initParam
cookie

放在request域中的如通过request.setAttribute("name","xy"),在页面中可以通过${ requestScope.name }

如xy.jsp?name=xy,就要通过${ param["name"] }获取

本文转自IT徐胖子的专栏博客51CTO博客,原文链接http://blog.51cto.com/woshixy/1008750如需转载请自行联系原作者


woshixuye111

相关文章
|
Java Apache 容器
Invalid <url-pattern> /admin/*.jsp in filter mapping
完成错误信息 严重: A child container failed during start java.util.concurrent.ExecutionException: org.apache.
1127 0
|
3月前
|
Java API Spring
spring注解中@RequestParam和@PathVariable的区别
spring注解中@RequestParam和@PathVariable的区别
28 0
|
4月前
|
前端开发 Java Spring
方法参数相关属性params、@PathVariable和@RequestParam用法与区别
方法参数相关属性params、@PathVariable和@RequestParam用法与区别
37 0
|
6月前
|
API
swagger2 注解说明 @ApiImplicitParam和@ApiImplicitParams的用法
swagger2 注解说明 @ApiImplicitParam和@ApiImplicitParams的用法
39 0
|
10月前
|
XML SQL JSON
@PathVariable、@RequestBody、@RequestParam、@ResponseBody、@Param的详解和用法
@PathVariable、@RequestBody、@RequestParam、@ResponseBody、@Param的详解和用法
121 0
|
11月前
|
Java API Spring
@RequestParam和@PathVariable的区别
@RequestParam注解获取URL中携带的请求参数的值既URL中“?”后携带的参数,传递参数的格式是:key=value;@PathVariable注解用于获取URL中路径的参数值,参数名由RequestMapping注解请求路径时指定,常用于restful风格的api中,传递参数格式:直接在url后添加需要传递的值即可
99 0
|
JSON 数据格式
@PathVariable,@RequestParam,@RequestBody区别
@PathVariable,@RequestParam,@RequestBody区别
|
JSON 前端开发 数据格式
@RequestParam、@RequestBody、@PathVariable区别和案例分析
@RequestParam、@RequestBody、@PathVariable区别和案例分析
127 2
@RequestParam和@PathVariable的作用
@RequestParam和@PathVariable的作用
240 0
@RequestParam和@PathVariable的作用
@RequestParam,@PathParam,@PathVariable等注解区别(上)
@RequestParam,@PathParam,@PathVariable等注解区别
178 0
@RequestParam,@PathParam,@PathVariable等注解区别(上)