JSP/ServletÖбàÂëÎÊÌâ½â¾ö·½°¸
Ê×ÏÈ£¬ËµËµJSP/ServletÖеļ¸¸ö±àÂëµÄ×÷Óá£
ÔÚJSP/ServletÖÐÖ÷ÒªÓÐÒÔϼ¸¸öµØ·½¿ÉÒÔÉèÖñàÂ룬pageEncoding="UTF-8"¡¢contentType="text/html;charset=UTF-8"¡¢request.setCharacterEncoding("UTF-8")ºÍresponse.setCharacterEncoding("UTF-8")£¬ÆäÖÐÇ°Á½¸öÖ»ÄÜÓÃÓÚJSPÖУ¬¶øºóÁ½¸ö¿ÉÒÔÓÃÓÚJSPºÍServletÖС£
1¡¢pageEncoding="UTF-8"µÄ×÷ÓÃÊÇÉèÖÃJSP±àÒë³ÉServletʱʹÓõıàÂë¡£
ÖÚËùÖÜÖª£¬JSPÔÚ·þÎñÆ÷ÉÏÊÇÒªÏȱ»±àÒë³ÉServletµÄ¡£pageEncoding="UTF-8"µÄ×÷ÓþÍÊǸæËßJSP±àÒëÆ÷ÔÚ½«JSPÎļþ±àÒë³ÉServletʱʹÓõıàÂ롣ͨ³££¬ÔÚJSPÄÚ²¿¶¨ÒåµÄ×Ö·û´®£¨Ö±½ÓÔÚJSPÖж¨Ò壬¶ø²»ÊÇ´Óä¯ÀÀÆ÷Ìá½»µÄÊý¾Ý£©³öÏÖÂÒÂëʱ£¬ºÜ¶à¶¼ÊÇÓÉÓڸòÎÊýÉèÖôíÎóÒýÆðµÄ¡£ÀýÈ磬ÄãµÄJSPÎļþÊÇÒÔGBKΪ±àÂë±£´æµÄ£¬¶øÔÚJSPÖÐÈ´Ö¸¶¨pageEncoding="UTF-8"£¬¾Í»áÒýÆðJSPÄÚ²¿¶¨ÒåµÄ×Ö·û´®ÎªÂÒÂë¡£
ÁíÍ⣬¸Ã²ÎÊý»¹ÓÐÒ»¸ö¹¦ÄÜ£¬¾ÍÊÇÔÚJSPÖв»Ö¸¶¨contentType²ÎÊý£¬Ò²²»Ê¹ÓÃresponse.setCharacterEncoding·½·¨Ê±£¬Ö¸¶¨¶Ô·þÎñÆ÷ÏìÓ¦½øÐÐÖØбàÂëµÄ±àÂë¡£
2¡¢contentType="text/html;charset=UTF-8"µÄ×÷ÓÃÊÇÖ¸¶¨¶Ô·þÎñÆ÷ÏìÓ¦½øÐÐÖØбàÂëµÄ±àÂë¡£
ÔÚ²»Ê¹ÓÃresponse.setCharacterEncoding·½·¨Ê±£¬ÓøòÎÊýÖ¸¶¨¶Ô·þÎñÆ÷ÏìÓ¦½øÐÐÖØбàÂëµÄ±àÂë¡£·þÎñÆ÷ÔÚ½«Êý¾Ý·¢Ë͵½ä¯ÀÀÆ÷Ç°£¬¶ÔÊý¾Ý½øÐÐÖØбàÂëʱ£¬Ê¹ÓõľÍÊǸñàÂë¡£
3¡¢request.setCharacterEncoding("UTF-8")µÄ×÷ÓÃÊÇÉèÖöԿͻ§¶ËÇëÇó½øÐÐÖØбàÂëµÄ±àÂë¡£
¸Ã·½·¨ÓÃÀ´Ö¸¶¨¶Ôä¯ÀÀÆ÷·¢ËÍÀ´µÄÊý¾Ý½øÐÐÖØбàÂ루»òÕß³ÆΪ½âÂ룩ʱ£¬Ê¹ÓõıàÂë¡£
4¡¢response.setCharacterEncoding("UTF-8")µÄ×÷ÓÃÊÇÖ¸¶¨¶Ô·þÎñÆ÷ÏìÓ¦½øÐÐÖØбàÂëµÄ±àÂë¡£
·þÎñÆ÷ÔÚ½«Êý¾Ý·¢Ë͵½ä¯ÀÀÆ÷Ç°£¬¶ÔÊý¾Ý½øÐÐÖØбàÂëʱ£¬Ê¹ÓõľÍÊǸñàÂë¡£
Æä´Î£¬ÒªËµÒ»Ëµä¯ÀÀÆ÷ÊÇÔõôÑù¶Ô½ÓÊպͷ¢Ë͵ÄÊý¾Ý½øÐбàÂëµÄ
response.setCharacterEncoding("UTF-8")µÄ×÷ÓÃÊÇÖ¸¶¨¶Ô·þÎñÆ÷ÏìÓ¦½øÐÐÖØбàÂëµÄ±àÂ롣ͬʱ£¬ä¯ÀÀÆ÷Ò²ÊǸù¾ÝÕâ¸ö²ÎÊýÀ´¶ÔÆä½ÓÊÕµ½µÄÊý¾Ý½øÐÐÖ
Ïà¹ØÎĵµ£º
×îºóÒ»´ÎJ2EE×÷Òµ£¬±»µÚ¶þСÌâÅ°µÃÓûËÀÓûÏÉ£¬Ëµµ½µ×¾ÍÊDZ»Á½¸öÎÊÌâÕÛÌÚÁË£¬Ò»¸öÊÇJPA£¬ÁíÒ»¸ö¾ÍÊÇÈçºÎÔÚJSPÖÐͨ¹ýButtonµ÷ÓÃJSP/Servlet¡£
ÔÚÍøÉϵÄÎÞÊýÖÐÓ¢ÎÄÌû×Ó¼äÑ°ÕÒ´ð°¸Ê±£¬ÓÐÒ»¸öÌû×ÓÈÃÎÒÓ¡ÏóÉî¿Ì¡£Ìû×ÓÊÇÕâô˵µÄ£ºµã»÷buttonÊÇÒ»¸ö¿Í»§¶ËµÄ¶¯×÷£¬µ÷ÓÃJSP/ServletÊÇ·þÎñÆ÷×öµÄÊ£¬Äã²»¿ÉÄÜÖ±½ÓÈÿͻ§¶Ëµ÷ÓÃJSP/Serv ......
²»ÒªÔÚJSPÖд¦ÀíÓû§ÇëÇó£¨request£©£¬Ò²²»ÒªÔÚJSPÖÐǶÈë¿ØÖÆÁ÷´úÂë
²»Òª½«Óû§½çÃ沿·ÖºÍÒµÎñÂß¼²¿·Ö»ìºÏ
ÔÚJSPÖо¡Á¿²»Òª°üº¬java´úÂ룬ELÔÚÕâ·½Ãæ¿ÉÒÔ¸øÎÒÃǺܴó°ïÖú
½«Ò³Ãæ·ÖΪ¼¸¸ö²¿·Ö£ºHeader£¬Menu£¬Main¡£¡£¡£
......
ѧϰËÑË÷ÒýÇ棬£¬·¢¾õjspµ÷ÓÃjava´óÖÂÓÐ3ÖÖ·½·¨¡£
µÚÒ»ÖÖ£¬Ê¹ÓÃjavabean¡£ÀýÈç
<jsp:useBean id="mm" class="com.ReadComm" scope="page"> </jsp:useBean>
classÖÐÌîдclass·¾¶¡£
µÚ¶þÖÖ£¬Ö±½ÓimportÒýÓÃjavaÀà
±ÈÈ磺 <%@ page import="java.util.*"%>
°ÑÄãµÄÀà·Åµ½WEB-INF\classesÏ£¬ÒýµÃʱ ......
¾³£¿´µ½jspµÄ³õѧÕßÎÊtomcatÏÂÈçºÎÅäÖÃjsp¡¢servletºÍbeanµÄÎÊÌ⣬ÓÚÊÇ×ܽáÁËÒ»ÏÂÈçºÎtomcatÏÂÅäÖÃjsp¡¢servletºÍben£¬Ï£Íû¶ÔÄÇЩ³õѧÕßÓÐËù°ïÖú¡£ µÚÒ»²½£ºÏÂÔØj2sdkºÍtomcat£ºµ½sun¹Ù·½Õ¾µã£¨http: //java.sun.com/j2se/1.4.2/download.html£©ÏÂÔØj2sdk£¬×¢ÒâÏÂÔذ汾Ϊ Windows Offline InstallationµÄSDK£¬Í¬Ê±×îºÃÏÂÔ ......
JDK»·¾³±äÁ¿ÅäÖãº
1.ÓÒ½¡µ¥»÷“ÎҵĵçÄԔͼ±êÑ¡Ôñ“ÊôÐÔ”£¬È»ºóÑ¡Ôñ“¸ß¼¶”Ñ¡Ï
µã»÷“»·¾³±äÁ¿”°´Å¥¡£
2.Ôړϵͳ±äÁ¿”ϵ¥»÷Ñ¡Ôñ“PATH”±äÁ¿£¬È»ºóµã»÷“±à¼”°´Å¥£»ÔÚ“±äÁ¿Öµ”Ò»À¸µÄ×îÇ°ÃæÌí¼Ó“c:\Java\jd ......