jpetstore学习第4章
经过前2章没有系统的看了PetSoreFacade 和OrderService之后,现在开始系统的学习了,就从系统登陆开始吧。
OK....
Let's go
First open /WEB-INF/jsp/struts/SignonForm.jsp
上来就是一个
<%@ include file="IncludeTop.jsp" %>
然后去看 IncludeTop.jsp
没什么特别的,只是定义了
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
2个taglib,哎,前2天刚刚被struts的taglib搞得头大,不过没事。
大概看了一下,这个文件基本上实现了页面的头部分的菜单导航栏,看一下用到了taglib有
<c:url value="/shop/index.do"/>">
<c:if test="${empty accountForm.account}" >
<c:forEach var="error" items="${errors}">
先恶补一下taglib吧,
还好我有google
http://java.sun.com/products/jsp/jstl/reference/api/index.html jstl的老巢
还找到2个文章
http://www.onjava.com/pub/a/onjava/2002/03/13/jsp.html
http://www.onjava.com/pub/a/pub/a/onjava/2002/05/08/jstl.html
好吧,先从这2个文章开始吧
另,刚刚上eclipse的网站上看一下,3.1M1出来了,拉一个下来玩玩再说,想当初,每天都上www.eclipse.org。只要有新版本。都会拉一个下来,也浪费了很多时间,现在想想真是浮躁,以后不能这样了。
哎,看了onjava的2个文章。没什么太大的感觉,还是回jstl的老巢吧
http://jakarta.apache.org/taglibs/doc/standard-doc/standard/GettingStarted.html
看看这个
首先
我想我用的最多的应该是Core和Fmt吧,好吧,就先不管别的了
开始吧
1. 输出
OK....
Let's go
First open /WEB-INF/jsp/struts/SignonForm.jsp
上来就是一个
<%@ include file="IncludeTop.jsp" %>
然后去看 IncludeTop.jsp
没什么特别的,只是定义了
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
2个taglib,哎,前2天刚刚被struts的taglib搞得头大,不过没事。
大概看了一下,这个文件基本上实现了页面的头部分的菜单导航栏,看一下用到了taglib有
<c:url value="/shop/index.do"/>">
<c:if test="${empty accountForm.account}" >
<c:forEach var="error" items="${errors}">
先恶补一下taglib吧,
还好我有google
http://java.sun.com/products/jsp/jstl/reference/api/index.html jstl的老巢
还找到2个文章
http://www.onjava.com/pub/a/onjava/2002/03/13/jsp.html
http://www.onjava.com/pub/a/pub/a/onjava/2002/05/08/jstl.html
好吧,先从这2个文章开始吧
另,刚刚上eclipse的网站上看一下,3.1M1出来了,拉一个下来玩玩再说,想当初,每天都上www.eclipse.org。只要有新版本。都会拉一个下来,也浪费了很多时间,现在想想真是浮躁,以后不能这样了。
哎,看了onjava的2个文章。没什么太大的感觉,还是回jstl的老巢吧
http://jakarta.apache.org/taglibs/doc/standard-doc/standard/GettingStarted.html
看看这个
首先
The constituent tag libraries of Standard Taglib are as follows:
| Funtional Area | URI | Prefix | Example |
|---|---|---|---|
| Core | http://java.sun.com/jsp/jstl/core |
c |
<c:tagname ...> |
| XML processing | http://java.sun.com/jsp/jstl/xml |
x |
<x:tagname ...> |
| I18N capable formatting | http://java.sun.com/jsp/jstl/fmt |
fmt |
<fmt:tagname ...> |
| Database access (SQL) | http://java.sun.com/jsp/jstl/sql |
sql |
<sql:tagname ...> |
| Functions | http://java.sun.com/jsp/jstl/functions |
fn |
fn:functionName(...) |
开始吧
1. 输出
<c:out value="expression" default="expression" escapeXml="boolean"/>
escapeXml 属性也是可选的。它控制当用 <c:out> 标记输出诸如“<”、“>”和“&”之类的字符(在 HTML 和 XML 中具有特殊意义)时是否应该进行转义。
如果将 escapeXml 设置为 true,则会自动将这些字符转换成相应的 XML 实体(此处提到的字符分别转换成 <、> 和 &)。
examples
1.1. Hello <c:out value="${user.username}" default=="Guest"/>!
1.2. <c:out value="${user.company}" escapeXml=="false"/>
2. 用缺省值设置变量
2.1 <c:set var="name" scope="scope" value="expression"/>
2.2 <c:set var="timezone" scope=="session">
<c:out value="${cookie['tzPref'].value}" default=="CST"/>
</c:set>
2.3 <c:set var="timezone" scope="session">CST</c:set>
2.4 <c:set var="timezone" scope="session" value="CST"/>
2.5 <c:set var="square" value="${param['x'] * param['x']}"/>
3.删除值
<c:remove var="timezone" scope="session"/>
4.判断
<c:choose>
<c:when test=<exception>>
</c:when>
<c:otherwise>
</c:otherwise>
</c:choose>
浙公网安备 33010602011771号