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

JSP±àÂëÒÔ¼°ÂÒÂë½â¾ö×ܽá

Ò»Ö±ÒÔÀ´¶ÔJSPÖгöÏÖÂÒÂëµÄÎÊÌⶼºÜ»ìÂÒ£¬ÏÖ¾­¹ý²éÔÄ×ÊÁÏ£¬¶ÔJSPÂÒÂëÕâ¸öÎÊÌâÓбȽÏÉî¿ÌµÄÈÏʶ£¬Ï±ßÊÇÎÒµÄһЩ¸öÈË×ܽᣬϣÍû¸øͬÑùÃÔ»óµÄÈË´øÀ´°ïÖú¡£ ͬʱÈç¹û²»¶Ô£¬Ï£ÍûµÃµ½ÌáÐÑ£¬¹²Í¬½ø²½¡£
Ê×ÏÈ£¬ËµËµJSP/ServletÖеļ¸¸ö±àÂëµÄ×÷Óãº
1.<%@page pageEncoding="UTF-8" %>
 ×÷Óãº
 * ¸æËßJSP±àÒëÆ÷ÔÚ½«JSPÎļþ±àÒë³ÉServletʱʹÓõıàÂ롣ͨ³££¬ÔÚJSPÄÚ²¿¶¨ÒåµÄ×Ö·û´®(Ö±½ÓÔÚJSPÖж¨Ò壬¶ø²»ÊÇ´Óä¯ÀÀÆ÷
   Ìá½»µÄÊý¾Ý)³öÏÖÂÒÂëʱ£¬ºÜ¶à¶¼ÊÇÓÉÓڸòÎÊýÉèÖôíÎóÒýÆðµÄ¡£ÀýÈ磬ÄãµÄJSPÎļþÊÇÒÔGBKΪ±àÂë±£´æµÄ
   (ÓÒ»÷jsp-->Properties --> Text file encodingÉèÖóÉÓëpageEncoding²»Ò»ÖÂʱ£¬¾ÍÓÐÂÒÂë)£¬¶øÔÚJSPÖÐÈ´Ö¸¶¨     
     pageEncoding="UTF-8"£¬¾Í»áÒýÆðJSPÄÚ²¿¶¨ÒåµÄ×Ö·û´®ÎªÂÒÂë
 * µ±JSPÖв»Ö¸¶¨contentType²ÎÊý£¬Ò²²»Ê¹ÓÃresponse.setCharacterEncoding·½·¨Ê±£¬Ö¸¶¨¶Ô·þÎñÆ÷ÏìÓ¦½øÐÐÖØбàÂëµÄ±àÂë
 
2.<%@page contentType="text/html;charset=GBK" %>»òresponse.setCharacterEncoding("UTF-8")
 ×÷Óãº
 * Ö¸¶¨¶Ô·þÎñÆ÷ÏìÓ¦½øÐÐÖØбàÂëµÄ±àÂë,·þÎñÆ÷ÔÚ½«Êý¾Ý·¢Ë͵½ä¯ÀÀÆ÷Ç°£¬¶ÔÊý¾Ý½øÐÐÖØбàÂë¡£
 * ä¯ÀÀÆ÷Ò²ÊǸù¾ÝÕâ¸ö²ÎÊýÀ´¶ÔÆä½ÓÊÕµ½µÄÊý¾Ý½øÐнâÂ룬¶ÔÆä·¢Ë͵ÄÇëÇó²ÎÊý½øÐбàÂë(Èç¹û²ÎÊýÓУº
   <%=URLEncoder.encode("²âÊÔ", "GBK") %>»òjavascript£ºencodeURI("²âÊÔ")ÔòÒÔºóÕßΪ׼)£¬×Ô¼º¿ÉÒÔÔÚIEµÄ²Ëµ¥ÖÐÑ¡Ôñ£º
   ²é¿´(V) --> ±àÂë(D)²é¿´µÃÖªä¯ÀÀÆ÷µÄ±àÂë(½âÂë)ºÍ<%@page contentType="text/html;charset=GBK" %>»ò
          response.setCharacterEncoding("UTF-8")ÉèÖõıàÂëÊÇÒ»Öµġ£
   Òò´Ë£ºÖ»ÒªÏìÓ¦½á¹û²»ÊÇÂÒÂ룬Ôòä¯ÀÀÆ÷ÏÔʾ½á¹ûÒ»¶¨²»»áÊÇÂÒÂë(·þÎñÆ÷¶ÔÏìÓ¦±àÂëºÍä¯ÀÀÆ÷¶ÔÏìÓ¦½âÂëµÄ±àÂëÊÇÒ»ÑùµÄ)¡£
   ³öÏÖÂÒÂëµÄÇé¿öÊÇ£ºä¯ÀÀÆ÷±àÂë ---> ·þÎñÆ÷½âÂëµÃµ½µÄ½á¹ûÊÇÂÒÂë ---> Ôì³ÉÏìÓ¦ÓÐÂÒÂë --> ä¯ÀÀÆ÷ÏÔʾÂÒÂë
3.<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 ×÷Óãº
 * ¿ØÖÆä¯ÀÀÆ÷µÄÒÔºÎÖÖ±àÂëÏÔʾÍøÒ³µÄÄÚÈÝ
 * Óë2ÖÐpageÖ¸ÁîÉèÖõÄÇø±ðÊÇ£¬metaÉèÖõÄÊÇä¯ÀÀÆ÷½âÊÍ£¬pageÉèÖõÄÊÇ·þÎñ¶Ë½âÊÍ
4.r


Ïà¹ØÎĵµ£º

½²½âJSP¹ýÂËÆ÷ºÍ¼àÌýÆ÷

     ¹ØÓÚÕâ¸öÎÊÌâ, ±È½Ï¸´ÔÓµÄ˵. ²»¹ýÎÒÏ£Íûͨ¹ýÀý×ÓÀ´½âÊͻ᷽±ãÀí½âһЩ.
¼ÙÉèÓÐÒ»¸ö·Ç³£Î£ÏÕµÄÈÎÎñ, ÊǾÅËÀÒ»Éú. ÐèÒªÄã´§×ÅÕ¨Ò©°ü´Ó±±Æ½¿ª³µ×߸ßËÙ·¹ý±£¶¨È¥Ê¯¼Òׯ°Ñ¹í×ӵĵﱤ¸øÕ¨ÁË. ×¢Òâ: Õâ¸öÈÎÎñÊ®·Ö¼è¾Þ, ÓпÉÄÜ°ë·ըҩ±¬Õ¨. ËùÒÔ³ö·¢Ç°ÄãÐèÒª¿àÁ·10ÔªÒ»±¾µÄ<<Ìú²¼ÉÀ>>, » ......

JUnitѧϰ±Ê¼Ç16 ÓÃJSPºÍtaglib½øÐе¥Ôª²âÊÔ3

ÓÃmock objects¶Ôtaglib½øÐе¥Ôª²âÊÔ    ÒòΪJSP²»ÊÇ´¿´âµÄjava´úÂ룬ËùÒÔ£¬Ê¹ÓÃmock½øÐвâÊÔÊÇÐв»Í¨µÄ£¬µ«ÊÇ£¬taglibÈ´ÊÇ´¿´âµÄjava´úÂ룬¿ÉÒÔ²âÊÔ£¬µ«ÊÇËüÒ²ÓÐÂé·³µÄµØ·½£¬ÎÒÃÇҪΪ³éÏóµÄjavaÀàµÄPageContext´´½¨mocks¡£    ÔÚÇ°Ã棬ÎÒÃÇÔøѧϰÁËʹÓÃEasyMockºÍDynaMockµÄ¿ò¼ÜÀ´´´½¨mock£¬µ«ÊÇ£¬ ......

¹ØÓÚJSPÒ³ÃæÓÃUTF 8±àÂëAJAXʧЧµÄÎÊÌâ

ÔÚÒ»¸öÏîÄ¿Öзּ¶Ñ¡ÔñÐÐÕþÇø»®Ê±Óõ½AJAX½øÐÐÎÞˢм¶Áª£¬ÎÒÔÚÒ³ÃæÖбàÂëÓõÄÊÇUTF-8£¬×ÜÊDZ¨½Å±¾´íÎó£¬
ÎÒ°ÑÒ³Ãæ±àÂë»»³ÉGBKÓÖÊÇÕý³£µÄ£¬ºóÀ´ÔÚÍøÉÏËÑË÷ÁËһϣ¬ÔÚÒýÈëJSʱ¼ÓÈë±àÂë¾Í¿ÉÒÔÁË£¬ÈçÏ£º
<script language="Javascript" src="js/jquery.js" charset="gb2312"></script> ......

Java Web µÚ9Ìì jsp 2

5.      

JSP
±ê×¼¶¯×÷¡¢
JSP
Ö¸ÁîÓÃÓÚÒ³ÃæÓëÈÝÆ÷¼äµÄͨÐÅ£¬¶ø
JSP
±ê×¼¶¯×÷ÓÃÓÚÒ³ÃæÓëÒ³Ãæ»òÕßÒ³ÃæÓë×é¼þ¼äµÄͨÐÅ¡£È磺
<jsp:include
page=”localURL” flush=”true”>
 
6.      

JSP
Òþʽ¶ÔÏó
ÔÚ
......

jspÒ³ÃæÓйرàÂëµÄ¹Ø¼ü´Ê½âÊÍ

<%@ page contentType=”text/html; charset=GB2312″ %>
<META http-equiv=Content-Type content=”text/html; charset=gb2312″>
 
pageEncoding ÊÇjspÎļþ±¾ÉíµÄ±àÂë
contentTypeµÄcharsetÊÇ·þÎñÆ÷·¢Ë͸ø¿Í»§¶ËµÄÄÚÈݵıàÂë¡£
 
 
ÔÚÍøÒ³µÄHTMLÔ´´úÂëÖÐÒ»¸öÖØÒªµ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ