以下是我的对Jstl的总结。这些代码包含的jstl的主要语法。
1.<%@ taglib uri='http://java.sun.com/jstl/core' prefix='c' %>
2.The pageContext implicit object lets you access the page context, which has references to the request, response, session, servlet context, servlet config, etc
<c:out value='${param.name}'/>
<c:forEach items='${initParam}' var='parameter'>
<ul>
<%-- Display the key of the current item, which
corresponds to the name of the init param --%>
<li>Name: <c:out value='${parameter.key}'/></li>
<%-- Display the value of the current item, which
corresponds to the value of the init param --%>
<li>Value: <c:out value='${parameter.value}'/></li>
</ul>
</c:forEach>
3.<c:if test='${not empty param.amount}'>
<c:out value='${param.amount}'/>
</c:if>
4.There's a lot more to the Core library than evaluating expressions and displaying the result; for example, you can implement if/then statements and switch constructs.
<c:choose>
<c:when test='${not empty param.name}'>
Hello <c:out value='${param.name}'/>.
</c:when>
<c:otherwise>
<font color='red'>
Please enter your name:<p>
</font>
<jsp:include page='index.jsp'/>
</c:otherwise>
</c:choose> '
5.<fmt:setLocale value='en-US'/>
<jsp:useBean id='today' class='java.util.Date'/>
<fmt:formatDate value='${today}' type='both'/>
6.<sql:transaction>
<%-- Withdraw money from the "from" customer's account --%>
<sql:update>
UPDATE ACCOUNTS SET BALANCE = BALANCE - ? WHERE CUST_ID = ?
<sql:param value='${param.amount}'/>
<sql:param value='${param.fromCustomer}'/>
</sql:update>
</sql:transaction>'
7.<c:out value='${param.amount}'/>
<c:forEach var='item' items='${names}' varStatus='status'>
The var and scope Attributes
<fmt:message key='index.greeting' var='msg' scope='request'/>
8.The expression language provides:
Expressions and identifiers
Arithmetic, logical, and relational operators
Automatic type coercion && (and) || (or) ! (not) empty
Access to beans, arrays, lists, and maps
Access to a set of implicit objects and servlet properties
9.<% // Create a string
String s = "Richard Wilson";
// Store the string in page scope
pageContext.setAttribute("name", s); %>
<%-- Access the string with an EL expression --%>
<c:out value='${name}'/>
10. if you have a Name bean stored in a scoped variable named name and that bean contains firstName and lastName properties, you can access those properties like this:
First Name: <c:out value='${name.firstName}'/>
First Name: <c:out value='${name["firstName"]}'/>
11.public class UserProfile {
private Name name;
private Address address;
}
<c:out value='${pageScope.profile.name.lastName}'/>:
10.Accessing Objects Stored in Arrays, Lists, and Maps
HashMap profileMap = new HashMap();
LinkedList profileList = new LinkedList();
JavaBean Component ${colorBean.red}
Array ${colorArray[2]} Array.get(colorArray, 2)
List colorList[2] colorList["2"] colorList.get(2)
Map colorMap[red] colorMap.get(pageContext.findAttribute("red"))
colorMap.get("red")
<select name='headerName'>
<c:forEach var='hdr' items='${header}'>
<option value='<c:out value="${hdr.key}"/>'>
<c:out value='${hdr.key}'/>
</option>
</c:forEach>
</select>
11.<c:choose>
<c:when test='${param.scope == "page"}'>
<c:set var='scope' value='${pageScope}'/>
</c:when>
</c:choose>
12.<c:forEach var='item' items='${listWrapper.list}'>
<li><c:out value='${item}'/></li>
</c:forEach>
13<c:forTokens items='ONE | TWO | THREE | FOUR'
delims='|' var='item'>
<c:out value='${item}'/>
</c:forTokens>
14 current Object The current item in the iteration
15.<%-- Set the locale for <fmt:message> actions to zh
(Chinese) --%>
<fmt:setLocale value='zh'/>
<c:out value='${pageContext.request.characterEncoding}'/>
分享到:
相关推荐
jstl总结资料自己的学习笔记jstl总结资料自己的学习笔记jstl总结资料自己的学习笔记
本人对jstl的一点小总结 JSTL是一个不断完善的开放源代码的JSP标签库,是由apache的jakarta小组来维护的。JSTL只能运行在支持JSP1.2和Servlet2.3规范的容器上,如tomcat 4.x。但是在即将推出的JSP 2.0中是作为标准...
JSTL常用标签总结,JSTL标签是开发中经常使用的技术,常用标签总结,希望对小伙伴们有帮助!
关于EL表达式和JSTL的总结。详细归纳EL表达式和JSTL的各种标签
自己总结的JSTL 核心标签 附上一定的源码 希望对大家有用
个人完整总结了jstl使用,个人在开发项目中总结,提供IT初学者
今天做项目,用到了el表达式和jstl,在tomcat6.0上跑得好好的,没想到copy到tomcat5.5后,服务器起不来了,是tomcat版本的问题。查阅了不少资料,现在总结如下: 错误信息: java.lang.NoClassDefFoundError: javax...
详细系统的介绍了jstl标签的使用和规范,是学习jstl的首选资料,非常值得收藏
记录一下JSTL和EL。
EL表达式使用方法总结以及显示结果,jstl标签库使用方法总结以及显示结果。
如果您学java它作为一个提纲挈领的东西还是不错的。另外我还将奉上IBM的java考试认证总结,也是比较概括,希望您能喜欢!
JSTL标签总结-,,,,,,,,,,<fmt>
总结了一些常用的jstl标签,jstl标准标签库,jstl-core核心标签库,jstl-functions标签库,对于学习jstl有所帮助
NULL 博文链接:https://jarorwar.iteye.com/blog/559091
全网最全最经典的jstl讲解,此文你下载你就是赚到,全部都是本人手工总结
本人学习中总结的jstl显示多条数据在jsp页面上,附带源码
jstl对集合操作大全-个人整理,这是个人平时总结知识点时总结出来的 ,分享给大家
这个是本人在安博培训的时候,学习JSTL的时候,总结的一套文档,希望对大家有所帮助
包含个人总结的,网上积累的,各种各种的jstl相关的东东
2.jsp运行原理-----jsp本质就是servlet(面试) jsp在第一次被访问时会被Web容器翻译成servlet,在执行 过程: 第一次访问---->helloServlet.jsp---->helloServlet_jsp.java---->编译运行 ...