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µÄpageEncoding="UTF-8",strutsµÄencoding="UTF-8"£¬eclipse µÄ¹¤×÷Çø¼äµÄ±àÂ뷽ʽÊÇGBK£¬µ«ÊÇÔÚstrutsµÄactionÖлñµÃµÄjsp´«À´µÄÖÐÎÄÖÐÓÐÂÒÂ룬ʹÓÃnew String(sysgkForm.getContent().getBytes("UTF-8"),"GBK")תÂëÒ²²»ÐУ¬×îºó·¢ÏÖÎÊÌâ³öÔÚÁËjspÀïÃæ¡£¼ÓÉÏcontentType="text/html; charset=GBK" ¾ÍºÃÁË¡£
pageEncodi ......
ÎÒÏÈ˵Ã÷Ò»ÏÂÅäÖû·¾³µÄ´ó¸ÅÇé¿ö£º
* FreeBSD 7.0-RELEASE
* apache-2.2.9
* mod_jk-ap2-1.2.26
* diablo-jdk-1.6.0.07.02
* tomcat-6.0.16
¾ßÌåµÄ°æ±¾ÐÅÏ¢ÏÔʾÈçÏ£º
freebsd# pkg_info
apache-2.2.9_5 Version 2.2.x of Apache web server&nbs ......
ÔÚÏîÄ¿ÖУ¬ÎÒÃǾ³£Óöµ½ÐèÒªÔÚjspÒ³ÃæÇл»Öд«µÝÖÐÎÄ×Ö·û¡£ÕâÖ÷ÒªÓÐÁ½ÖÖ·½Ê½¡£
¡¡¡¡URL·½Ê½£¬ÀýÈ磺http://website/test1.jsp?act=add&type=Æ»¹û¶m=%20D%20B
¡¡¡¡FORM·½Ê½£¬ÀýÈ磺
¡¡¡¡<form name=test mehtod="post">
¡¡¡¡<input type=hidden name=text2 value="ÖÐÎÄ">
¡¡¡¡<input type=t ......