zoukankan      html  css  js  c++  java
  • 关于Jsp ${param.xx}取出request.getParameter("xx")

    今天同事问起, 才发现有这种写法。 

    一番查询发现:这是因为 pageContext里面有很多隐式对象。

    其中包含了param,header,cookie对象。 

    param对象是包含了request中paramter的Map。


    oracle文档有提到。

    The Java EE 5 Tutorial  > Part II The Web Tier  > Chapter 5 JavaServer Pages Technology  > Unified Expression Language  > Implicit Objects 

    Implicit Objects

    The JSP expression language defines a set of implicit objects:

    • pageContext: The context for the JSP page. Provides access to various objects including:

    • In addition, several implicit objects are available that allow easy access to the following objects:

      • param: Maps a request parameter name to a single value

      • paramValues: Maps a request parameter name to an array of values

      • header: Maps a request header name to a single value

      • headerValues: Maps a request header name to an array of values

      • cookie: Maps a cookie name to a single cookie

      • initParam: Maps a context initialization parameter name to a single value

    • Finally, there are objects that allow access to the various scoped variables described in Using Scope Objects.

      • pageScope: Maps page-scoped variable names to their values

      • requestScope: Maps request-scoped variable names to their values

      • sessionScope: Maps session-scoped variable names to their values

      • applicationScope: Maps application-scoped variable names to their values

    JSP 2.1 provides two EL resolvers to handle expressions that reference these objects: ImplicitObjectELResolver and ScopedAttributeELResolver.

    A variable that matches one of the implicit objects is evaluated by ImplicitObjectResolver, which returns the implicit object. This resolver only handles expressions with a base of null. What this means for the following expression is that the ImplicitObjectResolver resolves the sessionScope implicit object only. Once the implicit object is found, the MapELResolver instance resolves the profile attribute because the profile object represents a map.

    ${sessionScope.profile}

    ScopedAttributeELResolver evaluates a single object that is stored in scope. Like ImplicitObjectELResolver, it also only evaluates expressions with a base of null. This resolver essentially looks for an object in all of the scopes until it finds it, according to the behavior of PageContext.findAttribute(String). For example, when evaluating the expression ${product}, the resolver will look for productin the page, request, session, and application scopes and will return its value. If product is not found, null is returned.

    When an expression references one of the implicit objects by name, the appropriate object is returned instead of the corresponding attribute. For example, ${pageContext} returns the PageContext object, even if there is an existing pageContext attribute containing some other value.


  • 相关阅读:
    使用winScp、putty导出mysql
    npm安装依赖
    node_modules文件夹出现.staging文件夹是怎么回事?
    jhipster生成工程
    npm使用国内淘宝镜像
    JAVA实现指定日期加几天
    php 使用ldap_connect方法连接AD时失败原因分析
    oracle中数据发生变动一定要commit 一定要commit 一定要commit
    Math中的round
    java中的实例变量和类变量的区别与联系:
  • 原文地址:https://www.cnblogs.com/thewindkee/p/12873173.html
Copyright © 2011-2022 走看看