jspѧϰ
<c:if>ÓÃÓÚ
Á÷³Ì¿ØÖÆ
Óï·¨
1:
<c:if
test=”testCondition” var=”varName”
[scope=”page|request|session|application”]/>
Óï·¨
2:
<c:if
test=”testCondition” var=”varName”
[scope=”page|request|session|application”]>
ÊôÐÔ
Ãû³Æ
˵Ã÷
EL
ÀàÐÍ
±ØÐë
ĬÈÏÖµ
test
Èç¹û±í´ïʽµÄ½á¹ûΪtrue
£¬ÔòÖ´Ðб¾ÌåÄÚÈÝ£¬false
ÔòÏà·´
Y
boolean
ÊÇ
ÎÞ
var
ÓÃÀ´´¢´ætest
ÔËËãºóµÄ½á¹û£¬¼´true
»òfalse
N
String
·ñ
ÎÞ
scope
var
±äÁ¿µÄJSP
·¶Î§
N
String
·ñ
page
eg£º
<%@ page
language="java" import="java.util.*"
pageEncoding="UTF-8"%>
<%@ taglib
uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
</head>
<body>
<h2><c:out value="<c:if>"/></h2>
<c:if
test="${param.username=='username' }" var="name"
scope="page">
hello,admin
</c:if>
<br>
result:${condition }
</body>
</html>
<c:choose> Ñ¡Ôñ±êÇ©
<c:choose>
±¾ÉíÖ»µ±×ö
<c:when>
ºÍ
<c:otherwise>
µÄ¸¸±êÇ©
Óï·¨
:
<c:choose>
±¾ÌåÄÚÈÝÖпÉÒÔº¬ÓÐ
(<when> <otherwise>)£¬¿ÉÒÔÓÉ1
»ò¶à¸ö
<c:when>£¬0
»ò
1
¸ö
<c:otherwise>
</c:choose>
<c:when> ±êÇ©
Óï·¨
:
<c:when
test=”testCondition”>
±¾ÌåÄÚÈÝ
<c:when>
ÊôÐÔ
Ãû³Æ
˵Ã÷
EL
ÀàÐÍ
±ØÐë
ĬÈÏÖµ
test
Èç¹û±í´ïʽµÄ½á¹ûΪtrue
£¬ÔòÖ´Ðб¾ÌåÄÚÈÝ£¬false
ÔòÏà·´
Y
boolean
ÊÇ
ÎÞ
<c:when>
±ØÐëÔÚ
<c:choose>
ºÍ
</c:choose>
Ö®¼ä
ÔÚͬһ¸ö
<c:choose>
ÖÐʱ£¬
<c:when>
±ØÐëÔÚ
<c:otherwise>
Ö®¼ä
<c:otherwise> ±êÇ©
ÔÚͬһ¸ö
<c:otherwise>
Ïà¹ØÎĵµ£º
¹Ø¼ü×Ö: jsp´«µÝÖÐÎIJÎÊý¡¢¿Õ¸ñÒÔ¼°±íµ¥ÄÚÈÝ»»ÐÐÎÊÌâ½â¾öС½á
ÔÚÀàËÆÁôÑÔ°åµÄwebÓ¦ÓÃÖУ¬ÐèÒª½«<textarea>ÖеĴó¶ÎÎÄ×ÖÏÔʾÔÚJspÒ³ÃæÉÏ£¬Òò´ËÐèÒª¶ÔÎÄ×ÖÖеÄÌØÊâ×Ö·ûÈç»»ÐС¢¿Õ¸ñµÄ×÷´¦Àí£¬·½·¨ÈçÏ£º
1¡¢Ö±½Ó±£´æ£¬È»ºóµ±´ÓÊý¾Ý¿âÖÐÈ¡³öÀ´Ê±ÓùýÂË·½·¨¹ýÂËÒ»±éÔÙËÍ»ØÒ³Ãæ¼´¿É£¬¸øÒ ......
ÔÚ¹ÜÀí¹¤¾ßÀïÃæÓÐÊý¾ÝÔ´ Ñ¡ÔñsqlÊý¾ÝÔ´
ÔÚ´úÂëÖУº
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<html>
<head>
<meta http-equiv="Content-Type" content= ......
Ò».ʲôÊÇcookies£¿
¡¡¡¡´ó¼Ò¶¼ÖªµÀ£¬ä¯ÀÀÆ÷ÓëWEB·þÎñÆ÷Ö®¼äÊÇʹÓÃHTTPÐÒé½øÐÐͨÐŵģ¬µ±Ä³¸öÓû§·¢³öÒ³ÃæÇëÇóʱ£¬WEB·þÎñÆ÷Ö»ÊǼòµ¥µÄ½øÐÐÏìÓ¦£¬È»ºó¾Í¹Ø±ÕÓë¸ÃÓû§µÄÁ¬½Ó¡£Òò´Ëµ±Ò»¸öÇëÇó·¢Ë͵½WEB·þÎñÆ÷ʱ£¬ÎÞÂÛÆäÊÇ·ñÊǵÚÒ»´ÎÀ´·Ã£¬·þÎñÆ÷¶¼»á°ÑËüµ±×÷µÚÒ»´ÎÀ´¶Ô´ý£¬ÕâÑùµÄ²»ºÃÖ®´¦¿ÉÏë¶øÖª¡£ÎªÁËÃÖ²¹Õâ¸öȱÏÝ£¬Netsc ......
<tr>
<td height="30" align="right">ÓòÃû£º</td>
<td align="left"><input name="domain" type="text" class="input" value="<%=request.getServerName()%>"/></td>
<td align="left">ϵͳÒѾ¼ì²â³öÄúµÄÓòÃû£¬ÇëÎð¸Ä¶¯</td>
</t ......
Cookie¸ÅÄî:
CookieµÄ¸ñʽʵ¼ÊÉÏÊÇÒ»¶Î´¿Îı¾ÐÅÏ¢, ÓÉ·þÎñÆ÷Ëæ×ÅÍøÒ³Ò»Æð·¢Ë͵½¿Í»§¶Ë, ²¢±£´æÔÚ¿Í»§¶ËÓ²ÅÌÖÐÖ¸¶¨µÄĿ¼µÄ. ´ó¼Ò¶¼´«ËµCookie»áÔì³ÉÑÏÖصݲȫÍþвʲôµÄ, Æäʵ²»ÊÇÕâô»ØÊÂÇé. ·þÎñÆ÷¶ÁÈ¡CookieµÄʱºò, Ö»Äܹ»¶ÁÈ¡µ½Õâ¸ö·þÎñÆ÷Ïà¹ØµÄÐÅÏ¢. ¶ø ......