Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÒýÓà JSP:contentType ÓëpageEncodingÇø±ð

pageEncoding
ÔÚJSP±ê×¼µÄÓï·¨ÖУ¬Èç¹ûpageEncodingÊôÐÔ´æÔÚ£¬ÄÇôJSPÒ³ÃæµÄ×Ö·û±àÂ뷽ʽ¾ÍÓÉpageEncoding¾ö¶¨£¬·ñÔò¾ÍÓÉcontentTypeÊôÐÔÖеÄcharset¾ö¶¨£¬Èç¹ûcharsetÒ²²»´æÔÚ£¬JSPÒ³ÃæµÄ×Ö·û±àÂ뷽ʽ¾Í²ÉÓÃĬÈϵÄISO-8859-1¡£
ContentType
ContentTypeÊôÐÔÖ¸¶¨ÁËMIMEÀàÐͺÍJSPÒ³Ãæ»ØӦʱµÄ×Ö·û±àÂ뷽ʽ¡£MIMEÀàÐ͵ÄĬÈÏÖµÊÇ“text/html”;
×Ö·û±àÂ뷽ʽµÄĬÈÏÖµÊÇ“ISO-8859-1”. MIMEÀàÐͺÍ×Ö·û±àÂ뷽ʽÓɷֺŸô¿ª
¹ØÓÚ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Îļþ²»ÊÇÕâÑù£¬ËüûÓÐÕâ¸öĬÈÏת


Ïà¹ØÎĵµ£º

jsp:forward±êÇ©ºÍresponse.sendRedirect()·½·¨µÄÇø±ð

ÔÚÍøÉÏ¿´µ½Ò»Ð©Ìû×Ó£¬×ܽáÁËһЩÇø±ð£¬¿ÉÒÔ´ÓÒÔϼ¸¸ö·½ÃæÀ´¿´£º
1.´ÓµØÖ·À¸ÏÔʾÀ´Ëµ
forwardÊÇ·þÎñÆ÷ÇëÇó×ÊÔ´,·þÎñÆ÷Ö±½Ó·ÃÎÊÄ¿±êµØÖ·µÄURL,°ÑÄǸöURLµÄÏìÓ¦ÄÚÈݶÁÈ¡¹ýÀ´,È»ºó°ÑÕâЩÄÚÈÝ
ÔÙ·¢¸øä¯ÀÀÆ÷.ä¯ÀÀÆ÷¸ù±¾²»ÖªµÀ·þÎñÆ÷·¢Ë͵ÄÄÚÈÝ´ÓÄÄÀïÀ´µÄ,ËùÒÔËüµÄµØÖ·À¸»¹ÊÇÔ­À´µÄµØÖ·.
redirectÊÇ·þÎñ¶Ë¸ù¾ÝÂß¼­,·¢ËÍÒ»¸ö×´ ......

JSPʵÀýÒ»¡¢¹ºÎï³µ


֪ʶ׼±¸£º
JDBC·ÃÎÊÊý¾Ý¿âµÄ»ù±¾²½Öè
£¨1£©¡¢½«Êý¾Ý¿âµÄJDBCÇý¶¯¼ÓÔص½¹¤³ÌÀà¿âÖС£
£¨2£©¡¢¼ÓÔØJDBCÇý¶¯£¬²¢½«Æä×¢²áµ½DriverManagerÖС£ÏÂÃæÊÇһЩÖ÷Á÷Êý¾Ý¿âµÄJDBCÇý¶¯¼ÓÔØ×¢²áÂ룺
¢Ù¡¢oracleÊý¾Ý¿â
Class.forName(“oracle.jdbc.driver.OracleDriver”).newInstance();
¢Ú¡¢Sql Server 7.0/2000Êý¾ ......

JSPÄÚÖöÔÏóÊôÐÔ¼°·½·¨´óÈ«

1.request¶ÔÏó
    ¿Í»§¶ËµÄÇëÇóÐÅÏ¢±»·â×°ÔÚrequest¶ÔÏóÖУ¬Í¨¹ýËü²ÅÄÜÁ˽⵽¿Í»§µÄÐèÇó£¬È»ºó×ö³öÏìÓ¦¡£ËüÊÇHttpServletRequestÀàµÄʵÀý¡£
ÐòºÅ                    ·½ ·¨      & ......

̸JSPÓëXMLµÄ½»»¥

̸JSPÓëXMLµÄ½»»¥
ʹÓÃJavaServer PagesÓÐÈýÖÖ²»Í¬µÄ·½·¨ÓÃÓÚ´¦ÀíXMLÎĵµ£¬Ã¿ÖÖ·½·¨¶¼ÓÐÀûÓÚÌá¸ß·ÖÀëÒ³Ãæ´úÂëÓëXMLÊý¾ÝµÄˮƽ£¬ÓÐÀûÓÚ¼ò»¯¿ª·¢ÍøÒ³µÄ¸´ÔӶȲ¢ÇÒ¸ÄÉÆÌá¸ß×é¼þÓëÒ³Ãæ´úÂëµÄ¿ÉÖØÓÃÐÔ¡£
¡¡¡¡JavaServer Pages ( JSP)ºÍXMLÊÇSunµÄJ2EEµÄÁ½¸öÖÁ¹Ø½ôÒªµÄ×é¼þ¡£ JSPÊÇÓÃÓÚ´´½¨Ó¦ÓóÌÐò·þÎñÆ÷¶Ë³ÌÐòµÄÓÐЧ¹¤¾ß£¬¶ø¿ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ