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

JSPÎļþµÄ±àÂëÊôÐÔpageEncodingÓëcontentTypeµÄÇø±ð


pageEncoding£ºÉèÖÃJSPÔ´ÎļþºÍÏìÓ¦ÕýÎÄÖеÄ×Ö·û¼¯±àÂë¡£
contentType£ºÉèÖÃJSPÔ´ÎļþºÍÏìÓ¦ÕýÎĵÄ×Ö·û¼¯±àÂë¼°MIMEÀàÐÍ¡£
¿É¼û,pageEncodingºÍcontentType¶¼¿ÉÒÔÉèÖÃJSPÔ´ÎļþºÍÏìÓ¦ÕýÎÄÖеÄ×Ö·û¼¯±àÂë¡£µ«Ò²ÓÐÇø±ð:
ÉèÖÃJSPÔ´Îļþ×Ö·û¼¯Ê±,ÓÅÏȼ¶ÎªpageEncoding>contentType¡£Èç¹û¶¼Ã»ÓÐÉèÖã¬Ä¬ÈÏISO-8859-1¡£
ÉèÖÃÏìÓ¦Êä³öµÄ×Ö·û¼¯Ê±,ÓÅÏȼ¶ÎªcontentType>pageEncoding¡£Èç¹û¶¼Ã»ÓÐÉèÖã¬Ä¬ÈÏISO-8859-1¡£
¿ÉÒÔ¼òµ¥ÈÏΪÊÇ£¬pageEncodingÊÇjspÎļþ±¾ÉíµÄ±àÂ룻contentTypeµÄcharsetÊÇÖ¸·þÎñÆ÷·¢Ë͸ø¿Í»§¶ËʱµÄÄÚÈݱàÂë¡£
ÀýÈ磺pageEncoding="GBK"¡£Õâ¾ä»°µÄÒâ˼ÊÇ£¬¸æËßJVM
Õâ¸öjsp±¾Éí²ÉÓõÄ"GBK"±àÂë,ÔÚJSP±àÒë³ÉServlet´«¸øJVMµÄʱºò£¬¾ÍÓÓGBK”µÄ±àÂ뷽ʽ½«JspÍøÒ³Ô´Îļþ·­Òë³ÉͳһµÄUTF-
8ÐÎʽµÄJava×Ö½ÚÂë¡£Èç¹û²»¼ÓÉ趨£¬ÔòJVMĬÈϵÄÓÃISO-8859-1ÕâÖÖ±àÂ뷽ʽ¡£contentTypeÀïµÄcharset=gbk£¬Ö¸µÄÊÇ
´ËÍøÒ³ÎļþÊä³öµ½ä¯ÀÀÆ÷µÄÊä³ö·½Ê½Îªgbk¡£ÔÚÕâ¸ö¹ý³ÌÖУ¬Ò»¸öJSPµÄÔ´ÎļþÐèÒª¾­¹ýÈý¸ö½×¶Î£¬Á½´Î±àÂ룬²ÅÄÜÍê³ÉÒ»´ÎÍêÕûµÄÊä³ö¡£
µÚÒ»½×¶Î£º½«jsp±àÒë³ÉServlet£¨.java£©Îļþ¡£Óõ½µÄÖ¸ÁîÊÇpageEncoding£¬¸ù¾ÝpageEncoding£½“XXX”µÄ
ָʾ£¬ÕÒµ½±àÂëµÄ¹æÔòΪ“XXX”£¬·þÎñÆ÷ÔÚ½«JSPÎļþ±àÒë³É.javaÎļþʱ»á¸ù¾ÝpageEncodingµÄÉ趨¶ÁÈ¡jsp£¬½á¹ûÊÇÓÉÖ¸¶¨µÄ±àÂë·½
°¸·­Òë³ÉͳһµÄUTF-8±àÂëµÄJAVAÔ´Â루¼´.java£©¡£
µÚ¶þ½×¶Î£º´ÓServletÎļþ£¨.java£©µ½Java×Ö½ÚÂëÎļþ£¨.class£©£¬´ÓUTF-8µ½UTF-8¡£ÔÚÕâÒ»½×¶ÎÖУ¬²»ÂÛJSP±àдʱºòÓõÄ
ÊÇʲô±àÂë·½°¸£¬¾­¹ýÕâ¸ö½×¶ÎµÄ½á¹ûÈ«²¿ÊÇUTF-8µÄencodingµÄjavaÔ´Âë¡£JAVACÓÃUTF-8µÄencoding¶ÁÈ¡javaÔ´Â룬±à
Òë³ÉUTF-8±àÂëµÄ¶þ½øÖÆÂ루¼´.class£©£¬ÕâÊÇJVM¶Ô³£Êý×Ö´®ÔÚ¶þ½øÖÆÂ루java
encoding£©ÄÚ±í´ïµÄ¹æ·¶¡£ÕâÒ»¹ý³ÌÊÇÓÉJVMµÄÄÚÔڹ淶¾ö¶¨µÄ£¬²»ÊÜÍâ½ç¿ØÖÆ¡£
µÚÈý½×¶Î£º´Ó·þÎñÆ÷µ½ä¯ÀÀÆ÷£¬ÕâÔÚÒ»¹ý³ÌÖÐÓõ½µÄÖ¸ÁîÊÇcontentType¡£·þÎñÆ÷ÔØÈëºÍÖ´ÐÐÓɵڶþ½×¶ÎÉú³É³öÀ´JAVA¶þ½øÖÆÂ룬Êä³öµÄ½á¹û£¬Ò²¾Í
ÊÇÔÚ¿Í»§¶Ë¿É¼ûµ½µÄ½á¹û£¬ÔÚÕâ´ÎÊä³ö¹ý³ÌÖУ¬ÓÉcontentTypeÊôÐÔÖеÄcharsetÀ´Ö¸¶¨£¬½«UTF8ÐÎʽµÄ¶þ½øÖÆÂëÒÔcharsetµÄ±àÂëÐÎ
ʽÀ´Êä³ö¡£Èç¹ûûÓÐÈËΪÉ趨£¬ÔòĬÈϵÄÊÇISO-8859-1µÄÐÎʽ¡£


Ïà¹ØÎĵµ£º

ASPÓëJSPµÄ±È½Ï

ASPÓëJSPµÄ±È½Ï
´Ó΢ÈíÍƳöÁËASP(ActiveServerPage)ºó£¬ËüÒÔÆäÇ¿´óµÄ¹¦ÄÜ£¬¼òµ¥Ò×ѧµÄÌصã¶øÊܵ½¹ã´óWEB¿ª·¢ÈËÔ±µÄϲ»¶¡£µ«ÊÇËüÈ´ÓÐ΢Èí²úÆ·µÄͨ²¡,Ö»ÄÜÔÚWindowsƽ̨ÏÂʹÓã¬ËäÈ»Ëü¿ÉÒÔͨ¹ýÔö¼Ó¿Ø¼þ¶øÔÚLINUXÏÂʹÓ㬵«ÊÇÆ书ÄÜ×îÇ¿´óµÄDCOM¿Ø¼þÈ´²»ÄÜʹÓ᣶øSUN¹«Ë¾ÔÚJAVAµÄ»ù´¡Ï¿ª·¢³öµÄJSP(Java ServerPages)ʵÏÖÁ˶ ......

jsp¹ýÂËÆ÷¼òд

package com.pan.encod;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
public class EncodFilter impl ......

JspÖеÄPageÖ¸Áî

PageÖ¸ÁîÊÇÓÃÀ´¶¨ÒåÕû¸öJspÒ³ÃæµÄÊôÐÔºÍÕâЩÊôÐÔµÄÖµ
¸ñʽ£º<%@ page Ö¸Áî±ê¼Ç="Öµ"%>
         pageÖеÄÖ÷ÒªÖ¸Áî±ê¼ÇÓÐÒÔϼ¸ÖÖ£º
         language£ºÉèÖÃJspÒ³ÃæÖÐÓõ½µÄÓïÑÔ£¬Ä¬ÈÏֵΪ"Java"
    &nbs ......

JspÖеÄrequest¶ÔÏó

     request¶ÔÏóÊÇjavax.servlet.HttpServletRequestÀàµÄÒ»¸ö×ÓÀà¶ÔÏ󣬵±¿Í»§¶ËÇëÇóÒ»¸öJspÒ³ÃæÊÇ£¬JspÈÝÆ÷»á½«¿Í»§¶ËµÄÇëÇóÐÅÏ¢°ü×°ÔÚÕâ¸ö¶ÔÏóÖУ»¸Ã¶ÔÏóÖеij£Ó÷½·¨ÈçÏ£º
getParameter(String name)£ºÒÔ×Ö·û´®µÄÐÎʽ·µ»Ø¿Í»§¶Ë´«À´µÄijһ¸öÇëÇó²ÎÊýµÄÖµ£¬²ÎÊýÃûÓÉnameÖ¸¶¨
getParameterNames() ......

JSPÁªÏµXMLÓëÊý¾Ý¿â

  Êý¾Ý¿âÓ¦ÓÃϵͳ°üÀ¨Êý¾Ý¿â£¬Êý¾Ý¿â¹ÜÀíϵͳ£¬Êý¾Ý¿âÓ¦ÓÃÈý´ó²¿·Ö¡£
  ÊÀ½çÉÏ´æÔÚÐí¶àÍêÈ«²»Í¬µÄ¿Í»§Æ½Ì¨£¬ÔÚ²»Í¬Æ½Ì¨¼ä½»»»Êý¾Ý£¬ÐèÒª±£Ö¤Êý¾ÝµÄÍêÕûºÍ·þÎñµÄ¸ßЧ£¬Êý¾Ý¸ñʽµÄת»»ÎÊÌâÍùÍù³ÉΪÖÆÔ¼Web ServiceµÄÆ¿¾±£¬²ÉÓÃXML×÷ΪÊý¾Ý½»»»µÄ±ê×¼£¬¿ÉÒÔʹ¸÷¸öÒ칹ƽ̨ºÍ¸÷ÖÖ¸ñʽµÄÊý¾Ý½øÐÐÊý¾Ý½»»»³ÉΪ¿ÉÄÜ¡£
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ