jspµÄpageEncodingºÍcontentType
pageEncodingÊÇjspÎļþ±¾ÉíµÄ±àÂë
contentTypeµÄcharsetÊÇÖ¸·þÎñÆ÷·¢Ë͸ø¿Í»§¶ËʱµÄÄÚÈݱàÂë
JSPÒª¾¹ýÁ½´ÎµÄ“±àÂ딣¬µÚÒ»½×¶Î»áÓÃpageEncoding£¬µÚ¶þ½×¶Î»áÓÃutf-8ÖÁutf-8£¬µÚÈý½×¶Î¾ÍÊÇÓÉTomcat³öÀ´µÄÍøÒ³£¬ ÓõÄÊÇcontentType¡£
µÚÒ»½×¶ÎÊÇjsp±àÒë³É.java£¬Ëü»á¸ù¾ÝpageEncodingµÄÉ趨¶ÁÈ¡jsp£¬½á¹ûÊÇÓÉÖ¸¶¨µÄ±àÂë·½°¸·Òë³ÉͳһµÄUTF-8 JAVAÔ´Â루¼´.java£©£¬Èç¹ûpageEncodingÉ趨´íÁË£¬»òûÓÐÉ趨£¬³öÀ´µÄ¾ÍÊÇÖÐÎÄÂÒÂë¡£
µÚ¶þ½×¶ÎÊÇÓÉJAVACµÄJAVAÔ´ÂëÖÁjava byteCodeµÄ±àÒ룬²»ÂÛJSP±àдʱºòÓõÄÊÇʲô±àÂë·½°¸£¬¾¹ýÕâ¸ö½×¶ÎµÄ½á¹ûÈ«²¿ÊÇUTF-8µÄencodingµÄjavaÔ´Âë¡£
JAVACÓÃUTF-8µÄencoding¶ÁÈ¡javaÔ´Â룬±àÒë³ÉUTF-8 encodingµÄ¶þ½øÖÆÂ루¼´.class£©£¬ÕâÊÇJVM¶Ô³£Êý×Ö´®ÔÚ¶þ½øÖÆÂ루java encoding£©ÄÚ±í´ïµÄ¹æ·¶¡£
µÚÈý½×¶ÎÊÇTomcat£¨»òÆäµÄapplication container£©ÔØÈëºÍÖ´Ðн׶ζþµÄÀ´µÄJAVA¶þ½øÖÆÂ룬Êä³öµÄ½á¹û£¬Ò²¾ÍÊÇÔÚ¿Í»§¶Ë¼ûµ½µÄ£¬ÕâʱÒþ²ØÔڽ׶ÎÒ»ºÍ½×¶Î¶þµÄ²ÎÊýcontentType¾Í·¢»ÓÁ˹¦Ð§
contentTypeµÄ設¶¨.
pageEncoding ºÍcontentTypeµÄÔ¤É趼ÊÇ ISO8859-1. ¶øËæ±ãÉ趨ÁËÆäÖÐÒ»¸ö, ÁíÒ»¸ö¾Í¸ú×ÅÒ»ÑùÁË(TOMCAT4.1.27ÊÇÈç´Ë). µ«Õâ²»ÊǾø¶ÔµÄ, ÕâÒª¿´¸÷×ÔJSPCµÄ´¦Àí·½Ê½. ¶øpageEncoding²»µÈÓÚcontentType, ¸üÓÐÀûÑÇÖÞÇøµÄÎÄ×Ö CJKVϵJSPÍøÒ³µÄ¿ª·¢ºÍչʾ, (ÀýpageEncoding=GB2312 ²»µÈÓÚ contentType=utf-8)¡£
jspÎļþ²»Ïñ.java£¬.javaÔÚ±»±àÒëÆ÷¶ÁÈëµÄʱºòĬÈϲÉÓõÄÊDzÙ×÷ϵͳËùÉ趨µÄlocaleËù¶ÔÓ¦µÄ±àÂ룬±ÈÈçÖйú´ó½¾ÍÊÇGBK£¬Ì¨Íå¾ÍÊÇBIG5»òÕßMS950¡£¶øÒ»°ãÎÒÃDz»¹ÜÊÇÔÚ¼Çʱ¾»¹ÊÇÔÚueÖÐд´úÂ룬Èç¹ûûÓо¹ýÌرðתÂëµÄ»°£¬Ð´³öÀ´µÄ¶¼ÊDZ¾µØ±àÂë¸ñʽµÄÄÚÈÝ¡£ËùÒÔ±àÒëÆ÷²ÉÓõķ½·¨¸ÕºÃ¿ÉÒÔÈÃÐéÄâ»úµÃµ½ÕýÈ·µÄ×ÊÁÏ¡£
µ«ÊÇjspÎļþ²»ÊÇÕâÑù£¬ËüûÓÐÕâ¸öĬÈÏתÂë¹ý³Ì£¬µ«ÊÇÖ¸¶¨ÁËpageEncoding¾Í¿ÉÒÔʵÏÖÕýȷתÂëÁË¡£
¾Ù¸öÀý×Ó:
<%@ page contentType="text/html;charset=utf-8" %>
´ó¶¼»á´òÓ¡³öÂÒÂ룬ÒòΪÊäÈëµÄ“ÄãºÃ”ÊÇgbkµÄ£¬µ«ÊÇ·þÎñÆ÷ÊÇ·ñÕýÈ·×¥µ½“ÄãºÃ”²»µÃ¶øÖª¡£
µ«ÊÇÈç¹û¸ü¸ÄΪ
<%@ page contentType="text/html;charset=utf-8" pageEncoding="GBK"%>
ÕâÑù¾Í·þÎñÆ÷Ò»¶¨»áÊÇÕýÈ·×¥µ½“ÄãºÃ”ÁË¡£
³ö´¦£ºhttp://blog.csdn.net/sunboard/archive/2008/12/23/3587855.aspx
Ïà¹ØÎĵµ£º
jspÂÒÂëÎÊÌ⣬ÇóÖú
ÏÂÁ˸ö¼¸ÄêÇ°µÄjspÔ´Â룬ÎÒ×°ÉϺóÒ»Ö±ÓÐÖÐÎÄÂÒÂëÎÊÌ⣬Êý¾Ý¿âÎÒÓÃmysql£¬
²¢ÓÃsql-front²Ù×÷£¬ÔÚÓÃsql-frontµÄʱºòÒÑ°Ñ×Ö·ûÉèÖÃΪgb2312£¬
¶øÇÒÔÚsql-frontÖÐÄÜÕýÈ·ÏÔʾÖÐÎÄ£¬µ«¾ÍÊÇÔÚjspÒ³ÃæÉÏÓÃgetstring·½·¨
µÃµ½ÂÒÂ룬ÎÒÒ²Óùýgetbytes£¨iso-8859-1£©µÈ·½·¨ÊÔ¹ý»¹ÊÇûÓÐ ......
ÎÒÏÖÔÚ¸øÄãÒ»¸öJAVAºÍJSPÖ®¼äµÄ¹Øϵ,ÒÔ¼°JAVAµÄÍêÕûÈÏʶ
JAVA·ÖΪJ2EE,J2SE.J2ME,ÏÂÃæ·Ö±ð½éÉÜ:
Ò».J2EE£ºJava 2 Platform Enterprise Edition ÆóÒµ°æ£¬ÓÃÓÚÆóÒµÓ¦Óã¬Ö§³Ö·Ö²¼Ê½²¿Êð¡£
J2EEƽ̨ÓÉÒ»ÕûÌ×·þÎñ£¨Services£©¡¢Ó¦ÓóÌÐò½Ó¿Ú£¨APIs£©ºÍÐÒé¹¹³É£¬
Ëü¶Ô¿ª·¢»ùÓÚWebµÄ¶à²ãÓ¦ÓÃÌṩÁ˹¦ÄÜÉϵÄÖ§³Ö¡£Ëü°ü ......
ѧϰJ2EE£¬±ØÐë¶ÔÏÂÃæµÄ¼¸¸ö¶ÔÏóÓкÜÉîµÄÀí½â
1¡¢request -> javax.servlet.http.HttpServletRequestµÄʵÀý
¸Ã¶ÔÏó·â×°ÁËÒ»´ÎÇëÇ󣬿ͻ§¶ËµÄÇëÇó²ÎÊý¶¼±»·â×°ÔڸöÔÏóÀï¡£ÕâÊÇÒ»¸ö³£ÓõĶÔÏ󣬻ñÈ¡¿Í»§¶ËÇëÇó²ÎÊý±ØÐëʹÓøöÔÏó¡£³£Óõķ½·¨ÓÐgetParameter(String pa ......
ÔÚÍøÉÏ¿´µ½ºÜ¶àÎÊÌâÊǹØÓÚÈçºÎѧϰjspµÄ£¬ÕýºÃÍøÉÏ¿´µ½Ò»Æª¹ØÓÚѧϰjspµÄÎÄÕ£¬¾ÍÕªÁËÒ»²¿·Ö·Òë¹ýÀ´£¬Ï£ÍûÄܶԴó¼ÒѧϰjspÓеãÖ¸µ¼¡£
¡¡¡¡Ò»¸öÆÕͨµÄ´íÎóÊÇ°ÑJSPµ±×÷¼ò»¯µÄ Java¡£Ëü²»ÊÇ£¬£¨ÊÂʵÉÏ, JSP ÊǼò»¯µÄ servlets ¡££©³ÌÐòԱͨ³£ÊÔ×ÅûÓÐѧϰҪÇóµÄÖ§³Ö¼¼ÇɶøÖ±½Óѧϰ JSP ¡£JSP ÊÇÒ»¸öÏνӼ¼Êõ£¬²¢Çҳɹ¦µØÁ¬½ ......
JSP»ù±¾Óï·¨
´ó²¿·ÖJSP±»Ò»¸öÒÔ“<%” ¿ªÍ·ºÍÒÔ“%>”½áβµÄµÄ±ê¼ÇÀ¨ÔÚÆäÖС£ÔÚ¸üеÄJSP 1.1¹æ·¶³ǫ̈ºó£¬¾ÍÓÐÁËÓëXML¼æÈݵİ汾¡£
JSPÖ¸ÁîºÍ½Å±¾ÔªËØ
Directives <%@ directive %>
Declarations <%! declaration %>
Expressions <%= expression %>
Code Fragment/ ......