JSP±àÂ볣ʶ[ת]
GBK±àÂë
GBK±àÂëÊÇÖйúÖƶ©µÄ¡¢µÈͬÓÚUCSµÄеÄÖÐÎıàÂëÀ©Õ¹¹ú¼Ò±ê×¼¡£GBK¹¤×÷С×éÓÚ1995Äê10Ô£¬Í¬Äê12ÔÂÍê³ÉGBK¹æ·¶¡£¸Ã±àÂë±ê×¼¼æÈÝGB2312£¬¹²ÊÕ¼ºº×Ö21003¸ö¡¢·ûºÅ883¸ö£¬²¢Ìṩ1894¸öÔì×ÖÂë룬¼ò¡¢·±Ìå×ÖÈÚÓÚÒ»¿â¡£
UTF-8±àÂë
UTF-8±àÂë¿ÉÒÔͨ¹ýÆÁ±ÎλºÍÒÆλ²Ù×÷¿ìËÙ¶Áд¡£×Ö·û´®±È½Ïʱstrcmp()ºÍwcscmp()µÄ·µ»Ø½á¹ûÏàͬ£¬Òò´ËʹÅÅÐò±äµÃ¸ü¼ÓÈÝÒס£×Ö½ÚFFºÍFEÔÚUTF-8±àÂëÖÐÓÀÔ¶²»»á³öÏÖ£¬Òò´ËËûÃÇ¿ÉÒÔÓÃÀ´±íÃ÷UTF-16»òUTF-32Îı¾£¨¼ûBOM£© UTF-8 ÊÇ×Ö½Ú˳ÐòÎ޹صġ£ËüµÄ×Ö½Ú˳ÐòÔÚËùÓÐϵͳÖж¼ÊÇÒ»ÑùµÄ£¬Òò´ËËüʵ¼ÊÉϲ¢²»ÐèÒªBOM¡£
GB2312
GB2312Ö§³ÖµÄºº×ÖÌ«ÉÙ¡£1995ÄêµÄºº×ÖÀ©Õ¹¹æ·¶GBK1.0ÊÕ¼ÁË21886¸ö·ûºÅ£¬Ëü·ÖΪºº×ÖÇøºÍͼÐηûºÅÇø¡£ºº×ÖÇø°üÀ¨21003¸ö×Ö·û¡£2000ÄêµÄGB18030ÊÇÈ¡´úGBK1.0µÄÕýʽ¹ú¼Ò±ê×¼¡£¸Ã±ê×¼ÊÕ¼ÁË27484¸öºº×Ö£¬Í¬Ê±»¹ÊÕ¼Á˲ØÎÄ¡¢ÃÉÎÄ¡¢Î¬Îá¶ûÎĵÈÖ÷ÒªµÄÉÙÊýÃñ×åÎÄ×Ö¡£ÏÖÔÚµÄPCƽ̨±ØÐëÖ§³ÖGB18030£¬¶ÔǶÈëʽ²úÆ·Ôݲ»×÷ÒªÇó¡£ËùÒÔÊÖ»ú¡¢MP3Ò»°ãÖ»Ö§³ÖGB2312¡£
´ÓASCII¡¢GB2312¡¢GBKµ½GB18030£¬ÕâЩ±àÂë·½·¨ÊÇÏòϼæÈݵģ¬¼´Í¬Ò»¸ö×Ö·ûÔÚÕâЩ·½°¸ÖÐ×ÜÊÇÓÐÏàͬµÄ±àÂ룬ºóÃæµÄ±ê×¼Ö§³Ö¸ü¶àµÄ×Ö·û¡£ÔÚÕâЩ±àÂëÖУ¬Ó¢ÎĺÍÖÐÎÄ¿ÉÒÔͳһµØ´¦Àí¡£Çø·ÖÖÐÎıàÂëµÄ·½·¨ÊǸß×Ö½ÚµÄ×î¸ßλ²»Îª0¡£°´ÕÕ³ÌÐòÔ±µÄ³Æºô£¬GB2312¡¢GBKµ½GB18030¶¼ÊôÓÚË«×Ö½Ú×Ö·û¼¯ (DBCS)¡£
Ò»¡¢JSPÒ³ÃæÏÔʾÂÒÂë
¶þ¡¢±íµ¥Ìá½»ÖÐÎÄʱ³öÏÖÂÒÂë
Èý¡¢Êý¾Ý¿âÁ¬½Ó
´ó¼ÒÔÚJSPµÄ¿ª·¢¹ý³ÌÖУ¬¾³£³öÏÖÖÐÎÄÂÒÂëµÄÎÊÌ⣬¿ÉÄÜÒ»ÖÁÀ§ÈÅ×ÅÄú£¬ÎÒÏÖÔÚ°ÑÎÒÔÚJSP¿ª·¢ÖÐÓöµ½
µÄÖÐÎÄÂÒÂëµÄÎÊÌâ¼°½â¾ö°ì·¨Ð´³öÀ´¹©´ó¼Ò²Î¿¼¡£
Ò»¡¢JSPÒ³ÃæÏÔʾÂÒÂë
ÏÂÃæµÄÏÔʾҳÃæ(display.jsp)¾Í³öÏÖÂÒÂ룺
<html>
<head>
<title>JSPµÄÖÐÎÄ´¦Àí</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<%
out.print("JSPµÄÖÐÎÄ´¦Àí");
%>
</body>
</html>
¶Ô²»Í¬µÄWEB·þÎñÆ÷ºÍ²»Í¬µÄJDK°æ±¾£¬´¦Àí½á¹û¾Í²»Ò»Ñù¡£ÔÒò£º·þÎñÆ÷ʹÓõıàÂ뷽ʽ²»Í¬ºÍä¯ÀÀÆ÷
¶Ô²»Í¬µÄ×Ö·ûÏÔʾ½á¹û²»Í¬¶øµ¼Öµġ£½â¾ö°ì·¨£ºÔÚJSPÒ³ÃæÖÐÖ¸¶¨±àÂ뷽ʽ(gb2312),¼´ÔÚÒ³ÃæµÄµÚÒ»
ÐмÓÉÏ£º
<%@ page contentType="text/html; charset=gb2312"%>
¾Í¿ÉÒÔÏû³ýÂÒÂëÁË¡£ÍêÕûÒ³ÃæÈçÏ£º
<%@ page contentType="text/html; charset=gb2312"%>
<html>
<head>
<t
Ïà¹ØÎĵµ£º
ÕâÖ÷ÒªÊÇtomcatµÄÎÊÌ⣬Ëü»áÔÚ´«Ë͵Äʱºò°Ñ×Ö·û¼¯ÖØбàÒ룬µÈ´«¹ýÈ¥µÄjspÒ³Ãæ½ÓÊܵÄʱºò¾Í»á³öÏÖÂÒÂ룬
²»¹ÜÔÚÒ³ÃæÀïÈçºÎÉèÖÃ×Ö·û¼¯¶¼Ã»°ì·¨½â¾ö£¬Õâʱºò±ØÐë±ØÐëÔÚtomcat°²×°Ä¿Â¼Àï½øÐÐÉèÖã¬
C:\Program Files\apache-tomcat-6.0.14\confĿ¼Ï server.xmlÏ <Connector/>±êÇ©Ï ¼ÓÒ»¾ä URIEncoding="GBK" ¾ÍºÃÁ ......
JSPÓëServletÖ®¼äµÄ»á»°¸ú×Ù·½Ê½Óжà¸ö£¬×¢¶¨ËûÃǵÄͨÐÅ·½Ê½ÓжàÖÖ¡£
ÏÂÃæÏÈÀ´¿´¿´4ÖлỰ¸ú×Ù·½Ê½£º
Ò»£ºSession
´«ËͶˣº
HttpSession session=request.getSession();
sessio ......
1¡¢ÈçºÎ»ìºÏʹÓÃJspºÍSSI #include?
ÔÚJSPÖпÉÒÔʹÓÃÈçÏ·½Ê½°üº¬´¿HTML£º
µ«ÊÇÈç¹ûdata.incÖаüº¬JSP CODE £¬ÎÒÃÇ¿ÉÒÔʹÓãº
2¡¢ÈçºÎÖ´ÐÐÒ»¸öḬ̈߳²È«µÄJSP?
Ö»ÐèÔö¼ÓÈçÏÂÖ¸Áî
3¡¢JSPÈçºÎ´¦ÀíHTML FORMÖеÄÊý¾Ý?
ͨ¹ýÄÚÖõÄrequest¶ÔÏó¼´¿É£¬ÈçÏ£º
String item = request.getParameter("item");
int howM ......
£¨1£©ÀûÓÃ<jsp:param name="paramName" value="paramValue"></jsp:param>ÆäÖÐnameΪÓëÊôÐÔÏà¹ØÁªµÄ¹Ø¼ü´Ê£¬valueΪÊôÐÔµÄÖµ¡£
ʾÀý£º´«³£Á¿×Ö·û´®<param name="userName" value="shilei"/>
ʾÀý£º´«±äÁ¿ User user=new User("shilei");//UserÊÇÒ»¸öÀà
&n ......