hwswl

 

JSTL标签应用指南(一)

:如何使用标签
         在jsp页面中使用JSTL标签之前,我们首先需要在该页顶部声明标签库的prefix(固定前缀)和URI(统一资源标识).我们要使用core JSTL库,那么我们就要使用标准的前缀(c).例如:

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>        

<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
二:表达式语言语法
   JSTL表达式${data}指明变量的范围,名称data.另外表达语言还支持以下固有的对象.      

范围对象

          含义

pageScope

页面范围变量

requestScope

请求范围变量

sessionScope

会话范围变量

applicationScope

应用程序范围变量

param

字符串类型格式的请求参数

paramValues

字符串集合类型的请求参数 

header

字符串类型的HTTP请求头部

headerValues

字符串集合类型的HTTP请求头部

initParam

上下文相关的初始化参数

cookie

Cookie值

pageContext

当前页的页上下文对象

              例如:表达式 ${param.username} 指明:请求范围.参数名称.
            其中:范围对象为:param;username为param对象内部的一个属性,对应于请求的一个参数。
            
   三:属性访问
      为了从集合中得到属性,JSTL表达式支持以下的操作:  

             1.点操作符标志命名属性,表达式${user.iq}表示:取出user对象的iq属性值;
               The dot (
. ) operator retrieves a named property. The expression ${user.iq}

                indicates the iq property of the scoped variable named user;

             2.使用[]操作符,可以使用序号检索出对应的属性的名字;
               The bracket (
[] ) operator lets you retrieve named or numbered properties;

             3.表达式${user["iq"]}和表达式${user.iq}含义一样;
               The expression
${user["iq"]} has the same meaning as ${user.iq}

             4.表达式${row[0]}取出行集合中的第一个元素(第一行);
               The expression
${row[0]} indicates the first item in the row collection.

posted on 2006-05-27 16:21 hwswl 阅读(373) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 

导航

统计

留言簿

我参与的团队

文章档案

搜索

最新评论