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>
Ïà¹ØÎĵµ£º
request, reponse, out, session, application, config, pagecontext, page, exception.
Ò».request¶ÔÏ󣺸öÔÏó·â×°ÁËÓû§Ìá½»µÄÐÅÏ¢£¬Í¨¹ýµ÷ÓøöÔÏóÏàÓ¦µÄ·½·¨¿ÉÒÔ»ñÈ¡·â×°µÄÐÅÏ¢£¬¼´Ê¹ÓøöÔÏó¿ÉÒÔ»ñÈ¡Óû§Ìá½»ÐÅÏ¢¡£
1.Request¶ÔÏó¿ÉÒÔʹÓÃgetParameter(string s)·½·¨»ñÈ¡¸Ã±íµ¥Í¨¹ýtextÌá½»µÄÐÅÏ¢¡£È磺
Requ ......
¼òµ¥µÄ˵°É¡£
requestµÄĬÈϱàÂ뷽ʽÊÇISO-8859-1¡£
jsp/htmlÀïÃæµÄcharsetÊôÐÔÊǽâÂëµÄ×Ö·û¼¯¡£
ÎÒÃÇҪͳһÓÃutf-8µÄ±àÂ뷽ʽ¡£
ËùÒÔÒª¶ÔrequestµÄ±àÂ뷽ʽ½øÐÐÉèÖã¬ÕâÑùд£º
request.seCharacterEncoding("utf-8");
È»ºó°ÑÊý¾Ý¿âµÄ±àÂ뷽ʽҲÉè³Éutf-8.
È»ºó¾Í²»»áÓÐÂÒÂë³öÏÖÁË¡£
ÂÒÂëÎÊÌâËãÊÇweb¿ª·¢Öо³£Óöµ½ ......
ÏÖÔÚÓкöà³õѧjspµÄÍøÓѾ³£»áÎÊÊý¾Ý¿âÔõôÁ¬½Ó°¡£¬ÔõôÀϳö´í°¡£¿ËùÒÔÎÒ¼¯ÖеÄÔÚÕâдƪÎÄÕ¹©´ó¼Ò²Î¿¼£¬ÆäʵÕâÖÖ°ÑÊý¾Ý¿âÂ߼ȫ²¿·ÅÔÚjspÀïδ±ØÊǺõÄ×ö·¨£¬µ«ÊÇÓÐÀûÓÚ³õѧÕßѧϰ£¬ËùÒÔÎÒ¾ÍÕâÑù×öÁË£¬µ±´ó¼Òѧµ½Ò»¶¨³Ì¶ÈµÄʱºò£¬¿ÉÒÔ¿¼ÂÇÓÃMVCµÄģʽ¿ª·¢¡£ÔÚÁ·Ï°ÕâЩ´úÂëµÄʱºò£¬ÄãÒ»¶¨½«jdbcµÄÇý¶¯³ÌÐò·Åµ½·þÎñÆ÷µÄÀà·¾ ......
¹Ø¼ü×Ö: jsp´«µÝÖÐÎIJÎÊý¡¢¿Õ¸ñÒÔ¼°±íµ¥ÄÚÈÝ»»ÐÐÎÊÌâ½â¾öС½á
ÔÚÀàËÆÁôÑÔ°åµÄwebÓ¦ÓÃÖУ¬ÐèÒª½«<textarea>ÖеĴó¶ÎÎÄ×ÖÏÔʾÔÚJspÒ³ÃæÉÏ£¬Òò´ËÐèÒª¶ÔÎÄ×ÖÖеÄÌØÊâ×Ö·ûÈç»»ÐС¢¿Õ¸ñµÄ×÷´¦Àí£¬·½·¨ÈçÏ£º
1¡¢Ö±½Ó±£´æ£¬È»ºóµ±´ÓÊý¾Ý¿âÖÐÈ¡³öÀ´Ê±ÓùýÂË·½·¨¹ýÂËÒ»±éÔÙËÍ»ØÒ³Ãæ¼´¿É£¬¸øÒ ......
ÔÚ¸÷ÖÖÍøÒ³ÖÆ×÷¼¼ÊõÂÛ̳ÖУ¬³£³£ÓÐÈËѯÎÊjavascriptÓëJavaÓÐʲôÇø±ð£¬ÉõÖÁÓÐÈËÎóÈÏΪjavascript¾ÍÊÇJava¡£javascriptÓëJavaȷʵÓÐÒ»¶¨µÄÁªÏµ£¬µ«ËüÃDz¢²»ÏñÎÒÃÇÏëÏóµÄÄÇÑùÁªÏµ½ôÃÜ£¬ÉõÖÁ¿ÉÒԿ϶¨µØ˵ËüÃÇÓкܴóµÄÇø±ð¡£
¡¡¡¡Ê²Ã´ÊÇJavaScript £¿
¡¡¡¡JavaScript ÊÇ¶Ô ECMA 262 Ó ......