c 标签
<c:out value="hello world!" default="" escapeXml=""></c:out>
attribute description value Expression to be evaluated.
required:true
rtexprvalue:truedefault Default value if the resulting value is null.
required:false
rtexprvalue:trueescapeXml Determines whether characters <,>,&,'," in the resulting string should be converted to their corresponding character entity codes. Default value is true.(是否按纯文本显示value的值,默认true,此时不能识别HTML标签;设为false时可以识别HTML标签)
required:false
rtexprvalue:true等价于<% out.println("hello world!");%>用于输出内容,如何输入域对象中的内容呢?(request,session,application,pageContext)<%request.setAttribute("a", "你好1");session.setAttribute("a", "你好2");application.setAttribute("a", "你好3");pageContext.setAttribute("a", "你好4");%><c:out value="${a}" default="null value." escapeXml=""></c:out>${a} 域对象中存在属性名相同时,搜索的顺序(优先级):pageContext > request > session > application,顾输出:你好4获取对象(User有两个属性:uname,pwd):<%User user = new User();user.setUname("zfq");user.setPwd("123");session.setAttribute("u", user);%><!-- User的uanme和pwd必须有get方法 --><c:out value="${u.uname}" default="null value." escapeXml="false"></c:out><c:out value="${u.pwd}" default="null value." escapeXml="false"></c:out>${u.uname } ${u.pwd } <!-- el表达式,可在里面做运算 -->
<c:set property="" value="中国" scope="request" target="" var="china"></c:set><c:set property="" value="中国1" scope="session" target="" var="china"></c:set><c:out value="${china }"></c:out>输出:中国c:set执行的内容多在控制器中就完成了,所以该标签用的时候不多
attribute description var Name of the exported scoped variable to hold the value specified in the action. The type of the scoped variable is whatever type the value expression evaluates to.
required:false
rtexprvalue:falsevalue Expression to be evaluated.
required:false
rtexprvalue:truetarget Target object whose property will be set. Must evaluate to a JavaBeans object with setter property property, or to a java.util.Map object.
required:false
rtexprvalue:trueproperty Name of the property to be set in the
target object.
required:false
rtexprvalue:truescope Scope for var.(request/session)不能是application和pageContext(指定域对象,默认)
required:false
rtexprvalue:false
<%request.setAttribute("attr", "Hello"); %><c:out value="${attr }"></c:out><br><c:remove var="attr" scope="request"/><c:out value="${attr }" default="null value"></c:out>输出:Hello
null value
attribute description var Name of the scoped variable to be
removed.
required:true
rtexprvalue:falsescope Scope for var.未指明则删除所有域对象的内容
required:false
rtexprvalue:false
<c:catch var="myException"><%int i = 8/0;%></c:catch><c:out value="${myException.message }"></c:out>输出:/ by zero
attribute description var Name of the exported scoped variable for the exception thrown from a nested
action. The type of the scoped variable
is the type of the exception thrown.
required:false
rtexprvalue:false
<%request.setAttribute("attr", "zfq");request.setAttribute("num", "25");%><c:if test="${attr=='zfq'}" var="cif" scope="session"><c:out value="ok"></c:out></c:if><br><c:if test="${cif }"><c:out value="not ok"></c:out></c:if><br><c:if test="${num > 12 }"><c:out value="num > 12"></c:out></c:if>输出:oknot oknum > 12
attribute description test The test condition that determines whether or not the body content
should be processed.
required:true
rtexprvalue:true
type:booleanvar Name of the exported scoped variable for the resulting value of the test condition. The type of the scoped variable is Boolean.
(把判断结果(bool值)放入域对象)
required:false
rtexprvalue:falsescope Scope for var.
required:false
rtexprvalue:false
attribute description null null
attribute description test The test condition that determines
whether or not the body content should be processed.
required:true
rtexprvalue:true
type:boolean
attribute description null null 6、7、8例子:<%Rat rat = new Rat();rat.setName("Jerry");rat.setAge(21);request.setAttribute("rat", rat);%><c:choose><c:when test="${rat.age <= 1 }"> <font color="red">老鼠太小不能吃!</font> </c:when><c:when test="${rat.age > 1 and rat.age <= 4}"> <font color="green">老鼠正在适吃年龄!</font> </c:when><c:when test="${rat.age > 4 and rat.age <= 20 }"> <font color="red">老鼠太老不好吃!</font> </c:when><c:otherwise><font color="red">老鼠已成精,敢吃吗?</font></c:otherwise></c:choose>
输出:老鼠已成精,敢吃吗?
<%ArrayList<Rat> rats = new ArrayList<Rat>();for(int i = 0;i < 5;i++){Rat rat = new Rat();rat.setAge(i+1);rat.setName("rat"+(i+1));rats.add(rat);}request.setAttribute("attr_rats", rats);%><c:forEach begin="0" end="4" items="${attr_rats}" step="1" var="rat" varStatus=""><c:out value="${rat.name } ${rat.age }"></c:out><br></c:forEach>输出:rat1 1
rat2 2
rat3 3
rat4 4
rat5 5
attribute description items Collection of items to iterate over.
required:false
rtexprvalue:true
type:java.lang.Object
deferred-value:java.lang.Objectbegin If items specified:
Iteration begins at the item located at
the specified index. First item of the
collection has index 0.
If items not specified:
Iteration begins with index set at the
value specified.
required:false
rtexprvalue:true
type:intend If items specified:
Iteration ends at the item located at the
specified index (inclusive).
If items not specified:
Iteration ends when index reaches the value
specified.
required:false
rtexprvalue:true
type:intstep Iteration will only process every step items
of the collection, starting with the first one.
required:false
rtexprvalue:true
type:intvar Name of the exported scoped variable for the
current item of the iteration. This scoped
variable has nested visibility. Its type
depends on the object of the underlying
collection.
required:false
rtexprvalue:falsevarStatus Name of the exported scoped variable for the
status of the iteration. Object exported is of type
javax.servlet.jsp.jstl.core.LoopTagStatus. This scoped
variable has nested visibility.
required:false
rtexprvalue:false
<%String s = "a,b,c";request.setAttribute("str", s);%><c:forTokens items="${str }" delims="," var="c">${c}</c:forTokens>输出:a b c
attribute description items String of tokens to iterate over.
required:true
rtexprvalue:true
type:java.lang.String
deferred-value:java.lang.Stringdelims The set of delimiters (the characters that
separate the tokens in the string).
required:true
rtexprvalue:true
type:java.lang.Stringbegin Iteration begins at the token located at the
specified index. First token has index 0.
required:false
rtexprvalue:true
type:intend Iteration ends at the token located at the
specified index (inclusive).
required:false
rtexprvalue:true
type:intstep Iteration will only process every step tokens
of the string, starting with the first one.
required:false
rtexprvalue:true
type:intvar Name of the exported scoped variable for the
current item of the iteration. This scoped
variable has nested visibility.
required:false
rtexprvalue:falsevarStatus Name of the exported scoped variable for the
status of the iteration. Object exported is
of type javax.servlet.jsp.jstl.core.LoopTag
Status. This scoped variable has nested
visibility.
required:false
rtexprvalue:false
<c:redirect context="" url="http://www.baidu.com"></c:redirect>跳转到百度首页
attribute description url The URL of the resource to redirect to.
required:false
rtexprvalue:truecontext Name of the context when redirecting to a relative URL
resource that belongs to a foreign context.
required:false
rtexprvalue:true
<c:import url="../a.jsp"><c:param name="uname" value="zfq"></c:param></c:import>JSP页面中访问参数:<body>A jsp page.<br>${param.uname}</body>
attribute description url The URL of the resource to import.
required:true
rtexprvalue:truevar Name of the exported scoped variable for the
resource's content. The type of the scoped
variable is String.
required:false
rtexprvalue:falsescope Scope for var.
required:false
rtexprvalue:falsevarReader Name of the exported scoped variable for the
resource's content. The type of the scoped
variable is Reader.
required:false
rtexprvalue:falsecontext Name of the context when accessing a relative
URL resource that belongs to a foreign
context.
required:false
rtexprvalue:truecharEncoding Character encoding of the content at the input
resource.
required:false
rtexprvalue:true
attribute description var Name of the exported scoped variable for the
processed url. The type of the scoped variable is
String.
required:false
rtexprvalue:falsescope Scope for var.
required:false
rtexprvalue:falsevalue URL to be processed.
required:false
rtexprvalue:truecontext Name of the context when specifying a relative URL
resource that belongs to a foreign context.
required:false
rtexprvalue:true
attribute description name Name of the query string parameter.
required:true
rtexprvalue:truevalue Value of the parameter.
required:false
rtexprvalue:true
c 标签的更多相关文章
- a标签点击跳转失效--IE6、7的奇葩bug
一般运用a标签包含img去实现点击图片跳转的功能,这是前端经常要用到的东西. 今天遇到个神奇的bug:如果在img上再包裹一层div,而且div设置了width和height,则图片区域点击时,无任何 ...
- IE6、7下html标签间存在空白符,导致渲染后占用多余空白位置的原因及解决方法
直接上图:原因:该div包含的内容是靠后台进行print操作,输出的.如果没有输出任何内容,浏览器会默认给该空白区域添加空白符.在IE6.7下,浏览器解析渲染时,会认为空白符也是占位置的,默认其具有字 ...
- 百度MIP页规范详解 —— canonical标签
百度MIP的规范要求必须添加强制性标签canonical,不然MIP校验工具会报错: 强制性标签<link rel="/^(canonical)$/"> 缺失或错误 这 ...
- 【CSS进阶】伪元素的妙用--单标签之美
最近在研读 <CSS SECRET>(CSS揭秘)这本大作,对 CSS 有了更深层次的理解,折腾了下面这个项目: CSS3奇思妙想 -- Demo (请用 Chrome 浏览器打开,非常值 ...
- TODO:Laravel 使用blade标签布局页面
TODO:Laravel 使用blade标签布局页面 本文主要介绍Laravel的标签使用,统一布局页面.主要用到到标签有@yield,@ stack,@extends,@section,@stop, ...
- 最新 去掉 Chrome 新标签页的8个缩略图
chrome的新标签页的8个缩略图实在让人不爽,网上找了一些去掉这个略缩图的方法,其中很多已经失效.不过其中一个插件虽然按照原来的方法已经不能用了,但是稍微变通一下仍然是可以用的(本方法于2017.1 ...
- css-父标签中的子标签默认位置
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>& ...
- xpath提取多个标签下的text
title: xpath提取多个标签下的text author: 青南 date: 2015-01-17 16:01:07 categories: [Python] tags: [xpath,Pyth ...
- 多个Img标签之间的间隙处理方法
1.多个标签写在一行 <img src="/i/eg_tulip.jpg" alt="郁金香" height="100px"/> ...
- html5标签canvas函数drawImage使用方法
html5中标签canvas,函数drawImage(): 使用drawImage()方法绘制图像.绘图环境提供了该方法的三个不同版本.参数传递三种形式: drawImage(image,x,y):在 ...
随机推荐
- hdu 2121 , hdu 4009 无定根最小树形图
hdu 2121 题目:给出m条有向路,根不确定,求一棵最小的有向生成树. 分析:增加一个虚拟节点,连向n个节点,费用为inf(至少比sigma(cost_edge)大).以该虚拟节点为根求一遍最小树 ...
- 【.NET基础】--委托、事件、线程(2)
本文介绍event的使用以及原理,本文接上一篇文章的Demo继续[下载上一篇Demo] 上一篇我们在类(dg_SayHi.cs)里面定义代理了4个Delegate,然后在Button的后台事件中 新建 ...
- 二维码扫描 zxing源码分析(三)result、history部分
前两个部分的地址是:ZXING源码分析(一)CAMERA部分 . zxing源码分析(二)decode部分 下面我们来看第三部分 result包下面有很多的类,其中的核心类是 com.google. ...
- arraylist寻址
首先感谢小不点儿同学提供的思路. 问题背景:把manage.aspx中的gridview列出的所有ID值传入下一个页面(放入arraylist,并通过session传递arraylist). 点击ID ...
- C#中 StringBuilder类 与 String类的区别---(转)
在找工作的时候,去了些公司,避免不了要面试和笔试.不过一般最起初的是笔试.我印象中有这样有一道题目:StringBuilder类与 String类的区别?那时候我不太清楚这两个类的区别,今天在看代 ...
- Express中使用mongodb存储session
express默认有队session的支持,但是是存储在内存中的. 我们可以使用mongodb来存储会话. 但是express的各个版本中对该功能的写法是不同的. Express 2.x: app.u ...
- linux下开发板网络速度测试记录
由于做的项目对于网络和USB的读写速度有很高的要求,因此新拿回来的板子要测试网络和usb的最佳传输速度.要考虑不少因素,先把我能想到的记录下来. 测试的环境是开发板和ubuntu虚拟机 ...
- C语言获取系统时间的几种方式[转]
C语言获取系统时间的几种方式 C语言中如何获取时间?精度如何? 1 使用time_t time( time_t * timer ) 精确到秒 2 使用clock_t clock() 得到的是CPU时间 ...
- javascript之Array基础篇
整理了 Array 中很基础的要掌握的知识点,希望可以帮助初学者,也希望自己以后多用多融会贯通. 创建数组 使用Array构造函数: var a=new Array();//创建一个空数组 var a ...
- 9 款赏心悦目的 HTML5/CSS3 特效
1.HTML5 WebGL实验,超酷的HTML5 Canvas波浪墙 这是一款HTML5 Canvas实验项目,也是波浪特效,只是这不是真正的水波,而是利用柱体高度的变化实现的波浪墙效果. 在线演示 ...