JSPÂÒÂëÖÕ¼«½â¾ö£¨ÊµÓã©
JspÊÇÒ»¸öºÜÈÈÃŵĻ°Ì⣬µ«Èôó¶àÊýÈ˶¼Í·Í´µÄÊÇJSPÒ³ÃæÖеÄÂÒÂëÎÊÌ⣬±ÊÕßÉíÓÐÌå»á£»ÔøΪÁ˽â¾öÖÐÎÄÂÒÂëÎÊÌâÓôÃÆÁ˺ü¸Ì죬ÊÔÁ˺ܶ෽·¨¶¼²»ÐС£×îºóÔÚJSPרҵÈËÊ¿µÄ°ïÖúÏ£¬ÖÕÓÚ½â¾ö¡£Ö®ºó±ÊÕßÔø¶Ô´Ë×öÁËһЩСµÄÑо¿¡£
Ê×ÏÈÎÒÃÇÏÈÁ˽âÒ»ÏÂÎÊÌâµÄÔÒò¡£Ò»°ãÇé¿öÔÚÔÚÿ¸öJSPÒ³µÄÍ·²¿¶¼ÓÐÕâÑùÒ»ÌõÓï¾ä£º
<% page contentType="text/html; charset=gb2312" %>ÕâÌõÓï¾ä¾ö¶¨ÁË´ËÒ³ÃæʹÓÃGB2312±àÂëÐÎʽ£¬¶øÔÚÊý¾Ý¿âÖÐÒ»°ãÓõÄÊÇiso-8859-1×Ö·û¼¯´æ´¢Êý¾Ý. ¶øJava³ÌÐòÔÚ´¦Àí×Ö·ûʱĬÈϲÉÓÃͳһµÄISO-8859-1×Ö·û¼¯(ÌåÏÖJava¹ú¼Ê»¯Ë¼Ïë),ËùÒÔÔÚÌí¼ÓÊý¾Ýʱ£¬Ä¬ÈϵÄ×Ö·û¼¯±àÂëÊÇiso-8859-1£¬¶øÒ³Ãæ²ÉÓõÄÊÇGB2312£¬ËùÒԾͳöÏÖÂÒÂëÎÊÌ⡣Ϊ½â¾ö´ËÎÊÌâÓ¦ÔÚ´æ´¢µÄʱºò°ÑGB2312»»×ª³Éiso-8859-1¡£ÓдËʱºòÔÚ¶Á³öʱҲ»á³öÏÖÂÒÂ룬ÄÇôֻÐè·´¹ýÀ´¾Í¿ÉÒÔÁË£¬°Ñiso-8859-1ת»»³ÉGB2312¡£
¾ßÌåʵÀý¹éÄÉÁËÒÔϼ¸µã£¬Ò²Ðí»á¶Ô´ó¼ÒÓÐһЩ°ïÖú¡£
1¡¢ ÔÚ½¨Á¢JSPÒ³ÃæʱӦ¸Ã×¢ÒâÔÚjspÒ³ÃæµÄÍ·²¿¼ÓÈëһϴúÂë
<% page contentType="text/html; charset=gb2312" %>
´Ë·½·¨Êǽâ¾öJSPÒ³ÃæÏÔʾʱµÄÂÒÂë¡£
2¡¢ ÓÐʱ»¹ÐèÔÚHTML´úÂëÖеÄ<head></head>ÖмÓÈëÕâ¾ä
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
3¡¢ ÔÚbeanÖÐÓõÄÊÇiso-8859-1±àÂ룬ÔÚjspÖÐÒ»°ãÓÃGB2312±àÂë,´¦Àí´ËÀàÂÒÂëÎÊÌâÈçÏÂ
String str=new String(strName.getBytes(“iso-8859-1”),”GB2312”);
¾ßÌåÓõ½´Ë·½·¨µÄµØ·½Îª£¬µ±Ìá½»±íµ¥µ½bean£¨beanµÄ¹¦ÄÜÊÇ´æ´¢Êý¾Ýµ½Êý¾Ý¿â£©±íµ¥Ìá½»ºó£¬Êý¾Ý¿âÖдæÈëµÄÊý¾ÝÈ·±ä³ÉÁË£¿£¿£¿£¿£¬Òò´ËÔÚµ÷ÓÃbean֮ǰӦ¶Ô±àÂë½øÐÐת»»£¬·½·¨£ºString str=new String(request.getParameter().getBytes(“iso-8859-1”),”GB2312”);
ÕâÑù£¬´æÈëÊý¾Ý¿âµÄÊý¾Ý¿âµÄÊý¾Ý¾Í¿É¼ûÁË¡£
4¡
Ïà¹ØÎĵµ£º
ÔÚʹÓÃÊý¾Ý¿âµÄ¹ý³ÌÖУ¬²»¿É±ÜÃâµÄÐèҪʹÓõ½·ÖÒ³µÄ¹¦ÄÜ£¬¿ÉÊÇJDBCµÄ¹æ·¶¶Ô´ËȴûÓкܺõĽâ¾ö¡£¶ÔÓÚÕâ¸öÐèÇóºÜ¶àÅóÓѶ¼ÓÐ×Ô¼ºµÄ½â¾ö·½°¸£¬±ÈÈçʹÓÃVectorµÈ¼¯ºÏÀàÏȱ£´æÈ¡³öµÄÊý¾ÝÔÙ·ÖÒ³¡£µ«ÕâÖÖ·½·¨µÄ¿ÉÓÃÐԺܲÓëJDBC±¾ÉíµÄ½Ó¿ÚÍêÈ«²»Í¬£¬¶Ô²»Í¬ÀàÐ͵Ä×ֶεÄÖ§³ÖÒ²²»ºÃ¡£ÕâÀïÌṩÁËÒ»ÖÖÓëJDBC¼æÈÝÐԷdz£ºÃµÄ·½°¸¡£
JD ......
1. servletÊÇÔÚjavaÀïǶÌ×html,jspÊÇÔÚhtmlÀïÃæǶÌ×java,jspÐèÒªÏȱàÒë³Éservlet²ÅÄÜÖ´ÐÐ.
2. jsp×îÖÕ·Òë³ÉservletÖ´ÐÐ.jspÈÝÒ×ÉÏÊֺͱàд¶øservletÐèÒª×Ô¼ºÊÖ¶¯±àÒë,ºÜÂé·³µÄ
3. servletÏÖÔÚ¸ü¶àÊdz䵱MVCÄ£ÐÍ¿ØÖÆÆ÷µÄ½ÇÉ«,ÓÉËü¸ù¾Ý¿Í»§µÄÇëÇó,À´¶¯Ì¬×éÖ¯·µ»ØÊý¾Ý»òÒ³ÃæµÄÖض¨Ïò,¶øJSPÖ»×öÏÔʾ(MVCÄ£ÐÍ,ÏÔʾ¿ØÖÆÄ£ÐÍ ÏÔ ......
ÔÚ±¾ÆªÎÄÕÂÖÐ,ÎÒÃǽ«»áÉîÈëÁ˽âÔÚ²»Í¬µÄTag LibraryÃèÊö·û(Tag Library Descriptors:TLDs)ÖÐʹÓø÷ÖÖ²»Í¬µÄtagµÄÇé¿ö.ÎÒÃǽ«»áÒÀ´ÎÑо¿ Ìõ¼þ¡¢Ñ»·¡¢URL¡¢U18N¡¢XMLµÈtagµÄÓ÷¨¡£ÒÔ´ËÀ´Ìá¸ßÄã¶ÔJSTLµÄÈÏʶºÍÓ¦ÓÃÄÜÁ¦,ÔÚÔĶÁ±¾ÎÄÇ°£¬ÄãÓ¦¸Ã¶Ô JSP Tag LibÓÐËùÁ˽⣬²¢ÇåÎúÓйØJSTL£¨JSP Standard Tag Libraries£©µÄ»ù± ......
ÍøÕ¾×öÍêºó£¬²¢²»ÊÇÖ±½Ó·Åµ½·þÎñÆ÷£¨Tomcat£©ÖÐÈ¥ÔËÐУ¬¶øÊÇÏȽ«Æä´ò°ü³ÉWarÎļþ£¬ÔÙ°ÑWarÎļþ·Åµ½·þÎñÆ÷ÖÐÈ¥ÔËÐУ¬ÄÇÑù¸ü·½±ã
ÄÇôÔõÑù½«Ò»¸öJspÍøÕ¾´ò°üÄØ£¿£¿£¿
Ò».·½·¨Ò»
½øÈëcmdµ½dosÃüÁîÐÐÏ£¬½øÈëJspWeb(×¢ÒâÒª½øÈëJspWebĿ¼£¬¼´½øÈëÄãÒª´ò°üµÄÍøÕ¾µÄ¸ùĿ¼)
ÔÙÏÂÒ»²½
......
ÔÚJspÖе÷ÓÃSerlvetÖÐÒѾ´æ´¢ÁËÐÅÏ¢µÄ JavaBean.
ServletÖÐÒѾ°ÑÊý¾Ý¿âµÄÐÅÏ¢±£´æµ½JavaBeanÖÐ,ÔÙ°ÑJavaBean±£´æµ½SessionÖÐ.
Jsp¿ªÊ¼µ÷ÓÃ:
<jsp:useBean id="key" type="ClassName" scope="Session" />
<jsp:getProperty name="key" property="PropertyName" />
ÎÞ·¨¶Á³öÐÅÏ¢:
ÔÒò: JavaBean ÖÐÊôÐÔµ ......