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

jspºÍServletÖÐÎÄÂÒÂë»ã×Ü

1.           jspÒ³ÃæÏÔʾÖÐÎÄÂÒÂ룺
 
jspÒ³ÃæµÄ±àÂ뷽ʽÓÐÁ½¸öµØ·½ÐèÒªÉèÖãº
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page contentType="text/html;charset=utf-8"%>
ÆäÖУºpageEncoding Ö¸µÄÊÇjspÎļþ±¾ÉíÔÚ±¾µØ±£´æʱµÄ±àÂ뷽ʽ¡£contentTypeµÄcharsetÊÇÖ¸·þÎñÆ÷·¢ËÍÍøÒ³ÄÚÈݸø¿Í»§¶ËʱËùʹÓõıàÂë¡£
´ÓµÚÒ»´Î·ÃÎÊÒ»¸öjspÒ³Ã濪ʼ£¬µ½Õâ¸öÒ³Ãæ±»·¢Ë͵½¿Í»§¶Ë£¬Õâ¸öJspÒ³ÃæÒª¾­¹ýÈý´Î±àÂëת»»£º
µÚÒ»½×¶ÎÊÇ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¾Í·¢»ÓÁ˹¦Ð§
 
ËùÒÔ×îÖյĽâ¾ö·½·¨Îª£º
ÔÚjspÒ³ÃæÉèÖÃpageEncoding»òÕßcontentTypeµÄÆäÖÐÒ»¸öΪ֧³ÖÖÐÎĵıàÂë¸ñʽ£¨Èçutf-8£¬gbk,gb2312£©¡£ÒòΪÉèÖÃÒ»¸öµÄ»°£¬ÁíÒ»¸öĬÈÏ»áºÍËüÒ»Ñù¡£
Èç¹ûÁ½¸ö¶¼ÉèÖõĻ°£¬±ØÐë±£Ö¤Á½¸ö¶¼ÊÇÖ§³ÖÖÐÎıàÂ루²»Ò»¶¨ÒªÒ»Ñù£©¡£
 ×î¼Ñ½¨ÒéÉèÖÃÈçÏ£º
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page contentType="text/html;charset=utf-8"%>
 
2.           post·½Ê½´«ÖµÂÒÂ룺
ÓÉÓÚpost·½Ê½´«ÖµÊÇͨ¹ýrequest´æ´¢µÄ£¬ÔÚÁíÒ»¸öÒ³ÃæÒ²ÊÇͨ¹ýrequest.getParameter(String name)À´ÌáÈ¡ÐÅÏ¢£¬ËùÒÔÕâÖÖÇé¿öϵÄÂÒÂëÖ÷ÒªÊÇÒòΪrequest´æ´¢ÐÅÏ¢µÄ±àÂëÉèÖõ¼Öµġ£postÌύʱ£¬Èç¹ûûÓÐÉèÖÃÌá½»µÄ±àÂë¸ñʽ£¬Ôò»áÒÔiso8859-1·½Ê½½øÐÐÌá½»£¬½ÓÊܵÄjspÈ´ÒÔutf-8µÄ·½Ê½½ÓÊÜ¡£ËùÒÔʹÓÃÈçÏÂÓï¾ä¼´¿ÉµÃµ½µ¥¸öÕýÈ·µÄÖÐÎÄ×Ö·û´®£ºString str = new String(request.getParameter("something").getBytes("ISO-8859-1"),"utf-8


Ïà¹ØÎĵµ£º

JSP»ù´¡

Ò»¡¢JSP¼ò½é
JSP (Java Server Pages)ÊÇ·þÎñÆ÷¶ËµÄ½Å±¾ÓïÑÔ£¬ÊÇÒ»ÖÖÔÚHTMLÒ³ÃæÖмÓÈëJavaÓïÑÔ¶øÉú³É¶¯Ì¬Ò³ÃæµÄ¼¼Êõ£º¼ÓÈëÁËеıêÇ©£¨<%£¬%>£¬…£©¡£
JSPÊÇÒÔJavaºÍServletΪ»ù´¡¿ª·¢¶ø³ÉµÄ¶¯Ì¬ÍøÒ³Éú³É¼¼Êõ£¬ËüµÄµ×²ãʵÏÖÊÇJava Servlet¡£
JSPÒ³ÃæÓÉHTML´úÂëºÍǶÈëÆäÖеÄJava´úÂëËù×é³É¡£·þÎñÆ÷ÔÚÒ³Ãæ±»¿Í» ......

jsp´«µÝÖÐÎIJÎÊý¡¢¿Õ¸ñÒÔ¼°±íµ¥ÄÚÈÝ»»ÐÐÎÊÌâ½â¾öС½á


¹Ø¼ü×Ö: jsp´«µÝÖÐÎIJÎÊý¡¢¿Õ¸ñÒÔ¼°±íµ¥ÄÚÈÝ»»ÐÐÎÊÌâ½â¾öС½á

ÔÚÀàËÆÁôÑÔ°åµÄwebÓ¦ÓÃÖУ¬ÐèÒª½«<textarea>ÖеĴó¶ÎÎÄ×ÖÏÔʾÔÚJspÒ³ÃæÉÏ£¬Òò´ËÐèÒª¶ÔÎÄ×ÖÖеÄÌØÊâ×Ö·ûÈç»»ÐС¢¿Õ¸ñµÄ×÷´¦Àí£¬·½·¨ÈçÏ£º
1¡¢Ö±½Ó±£´æ£¬È»ºóµ±´ÓÊý¾Ý¿âÖÐÈ¡³öÀ´Ê±ÓùýÂË·½·¨¹ýÂËÒ»±éÔÙËÍ»ØÒ³Ãæ¼´¿É£¬¸øÒ ......

JSÓëJSPµÄÇø±ð(תÔØ)


ÔÚ¸÷ÖÖÍøÒ³ÖÆ×÷¼¼ÊõÂÛ̳ÖУ¬³£³£ÓÐÈËѯÎÊjavascriptÓëJavaÓÐʲôÇø±ð£¬ÉõÖÁÓÐÈËÎóÈÏΪjavascript¾ÍÊÇJava¡£javascriptÓëJavaȷʵÓÐÒ»¶¨µÄÁªÏµ£¬µ«ËüÃDz¢²»ÏñÎÒÃÇÏëÏóµÄÄÇÑùÁªÏµ½ôÃÜ£¬ÉõÖÁ¿ÉÒԿ϶¨µØ˵ËüÃÇÓкܴóµÄÇø±ð¡£ 
¡¡¡¡Ê²Ã´ÊÇJavaScript £¿ 
¡¡¡¡JavaScript ÊǶԠECMA 262 Ó ......

JSP Ò³Ã滺´æÒÔ¼°Çå³ý»º´æ

Ò»¡¢¸ÅÊö
    »º´æµÄ˼Ïë¿ÉÒÔÓ¦ÓÃÔÚÈí¼þ·Ö²ãµÄ¸÷¸ö²ãÃæ¡£ËüÊÇÒ»ÖÖÄÚ²¿»úÖÆ£¬¶ÔÍâ½ç¶øÑÔ£¬ÊDz»¿É¸ÐÖªµÄ¡£
    Êý¾Ý¿â±¾ÉíÓлº´æ£¬³Ö¾Ã²ãÒ²¿ÉÒÔ»º´æ¡££¨±ÈÈ磺hibernate£¬»¹·Ö1¼¶ºÍ2¼¶»º´æ£©
    ÒµÎñ²ãÒ²¿ÉÒÔÓлº´æ£¨µ«Ò»°ãÀ´Ëµ£¬ÕâÊÇÒ»¸ö¹ý³ÌÓò£¬²»»áÉ軺´æ£©¡£
&nbs ......

webʵÑ鱨¸æ——JSP¶¯Ì¬ÍøÒ³±à³Ì

ʵÑ鱨¸æ
Ò». »ù±¾Ë¼Â·¼°ÊµÑé½á¹û£¨¼Ç¼¸÷ÖÖÔËÐÐÇé¿ö»òÒ³ÃæµÄÔËÐÐЧ¹û£©£»
1¡¢Ê¹ÓÃTOMCAT·þÎñÆ÷ÅäÖÃjspÓ¦ÓÃ
1£©´ò¿ªTOMCAT/webapps×ÓĿ¼£¬´´½¨Ò»webÓ¦Óã¨Èçmyweb£©£¬½«example0.jspÓëexample1.jspÎļþ¸´ÖÆÈëÄÚ£¬²¢ÔÚ¸ÃĿ¼ÏÂÉèÖÃWEB-INFĿ¼¼°web.xmlÅäÖÃÎļþ£»
2£©ÔÚä¯ÀÀÆ÷µØÖ·À¸ÊäÈëhttp://localhost:8080/myweb/ex ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ