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

JSPÖеÄinclude »úÖÆ

±¾ÎÄÊÇÐ嵀 JSP ×î¼Ñʵ¼ùϵÁÐÎÄÕµĵÚÒ»²¿·Ö£¬Ëü½éÉÜÁË JavaServer Pages include »úÖÆ¡£Çë¸úËæ Java ±à³Ìר¼Ò Brett McLaughlin ѧϰÈçºÎʹÓà include ½«¾²Ì¬µÄÍ·ÎļþºÍ½Å×¢Îļþ¼ÓÈëÄúµÄÍøÕ¾»ò Web Ó¦ÓóÌÐòÒ³ÃæÖС£
»¶Ó­ÔĶÁ Java רÇøÖÐ×îеÄ×î¼Ñʵ¼ùϵÁÐÎÄÕ¡£Èç¹ûÄú¿´¹ýÏÈÇ°µÄϵÁÐÎÄÕ£¬ÄÇôÄú»áÖªµÀ×î¼Ñʵ¼ùÖ¼ÔÚÈÃÄú¿ìËÙÁ˽â¸÷ÖÖ Java ¼¼ÊõµÄÓÐÓ÷½Ãæ¡£ÕâһϵÁеÄ×î¼Ñʵ¼ùרÃÅÌÖÂÛ JavaServer Pages£¨JSP£©¼¼Êõ£¬ËüÊǺËÐÄ J2EE ¼¼ÊõÖ®Ò»¡£ 
¼ò¶øÑÔÖ®£¬JSP ¼¼ÊõÊÇÔÚ Java ƽ̨ÉϹ¹½¨ Web Ò³Ãæ»ò Web Ó¦ÓóÌÐò½Ó¿ÚµÄ¹¤¾ß¡£JSP ¼¼ÊõÔÊÐíÎÒÃÇ×öÈçÏÂÊÂÇ飺¶¯Ì¬ÏìÓ¦ÇëÇóÊý¾Ý¡¢ÏÔʾ¸´Ô XML ºÍ HTML ÒÔ¼°´´½¨Éú¶¯ÓÐȤ¡¢¶¯Ì¬Çý¶¯µÄÍøÕ¾¡£ÔÚ±¾ÏµÁÐÖУ¬Äú½«Ñ§Ï°Ò»Ð©Óà JSP ¼¼Êõ¹¹½¨ÍøÕ¾µÄ»ù´¡ÖªÊ¶¡£ÎÒ½«ÎªÄú½éÉÜ×î³£ÓÃµÄ JSP »úÖÆ£¬Í¨¹ýÕâЩ»úÖÆ£¬Äú½«Á˽â»ù±¾µÄ Web ¿ª·¢¼¼Êõ£¬ÈçÖÆ×÷Ä£°å¡¢²Ù×÷¶¯Ì¬ÄÚÈÝ¡¢Í¼ÏñÍйܡ¢´´½¨ÊµÓóÌÐò´úÂë¿âµÈ¡£
±¾ÎÄÊÇÕâһϵÁÐÎÄÕµĵÚһƪ£¬ÔÚ±¾ÎÄÖУ¬ÎÒÃǽ«¼¯ÖÐÌÖÂÛ JSP include »úÖÆ£¬¸Ã»úÖÆÔÊÐíÎÒÃÇ“À­”Èë±¾µØ HTML Ò³ÃæµÄÄÚÈÝ¡£ÎÒÃǽ«Ê×ÏȽéÉÜÓÐ¹Ø Web Ò³Ãæ include ·¢Õ¹µÄһЩ±³¾°ÖªÊ¶£¬ÓÈÆäÊÇ¿ò¼ÜºÍ·þÎñÆ÷¶Ë include µÄʹÓá£È»ºó£¬ÎÒ½«ÏòÄúÑÝʾÈçºÎʹÓà JSP include »úÖƽ«Í³Ò»µÄÍ·ÎļþºÍ½Å×¢ÎļþÌí¼Óµ½ Web Ò³Ãæ»ò Web Ó¦ÓóÌÐòÆÁÄ»¡£
· JSP ×î¼Ñʵ¼ùϵÁÐ
±¾ÏµÁÐÎÄÕ²¢²»´òËãÍêÕûµØ½éÉÜ JSP ¼¼Êõ£¬Ò²²»´òËã×÷ΪÈçºÎ¹¹½¨ÌØÊâÀàÐÍÓ¦ÓóÌÐòµÄÖ¸ÄÏ¡£Ïà·´£¬ÏµÁÐÎÄÕÂÖеÄÿ¸ö²¿·Ö¶¼¼¯ÖÐÌÖÂÛÓà JSP ¼¼Êõ±à³ÌµÄijһ¸ö·½Ã棬½«Ëü·Ö³ÉºÜСµÄƬ¶Î¡£ÓÐ¹Ø JSP ¼¼ÊõµÄ¸ü¹ã·º½éÉÜ»òÕ߶ÔÈçºÎ½«ËüÓÃÓÚÌØÊâ½á¹ûµÄ¸üÉîÈëÑо¿£¬Çë²ÎÔIJο¼×ÊÁϲ¿·Ö¡£
Äú½«ÐèҪʲô
±¾ÏµÁÐÎÄÕÂÖеÄËùÓÐ×î¼Ñʵ¼ù¶¼»ùÓÚ JavaServer Pages ¼¼Êõ¡£ÒªÔËÐÐÈκÎÒ»ÖÖʵ¼ù£¬ÐèÒªÔÚ±¾µØ»úÆ÷»ò²âÊÔ·þÎñÆ÷ÉÏÉèÖ÷ûºÏ JSP µÄ Web ÈÝÆ÷£¬Èç Apache Tomcat¡£Äú»¹ÐèҪʹÓÃÎı¾±à¼­Æ÷»ò IDE ±àд JSP Ò³Ãæ´úÂë¡£Çë²ÎÔIJο¼×ÊÁÏ£¬»ñÈ¡ Tomcat ºÍÓë JSP ¼æÈÝµÄ Web ÈÝÆ÷ºÍ IDE µÄÇåµ¥µÄÁ´½Ó¡£
· ¸üºÃµÄÍâ¹Û
Ϊ Web Ò³Ãæ´´½¨Ò»ÖµÄÉè¼ÆºÍ²¼¾ÖÊÇÈ·±£»ñµÃרҵ»¯Íâ¹ÛµÄ×îÈÝÒ×·½·¨Ö®Ò»¡£Äú»òÐí¿´¹ý×ã¹»¶àµÄÍøÕ¾£¬ÖªµÀµ¥¸öÕ¾µãÖеĴ󲿷ÖÒ³Ã涼¹²ÓÃͳһµÄÒ³ÃæÍ·¡¢Ò³ÃæβÒÔ¼°Ä³ÖÖÀàÐ͵ĵ¼º½À¸¡£ÔÚÉè¼ÆÁ¼ºÃµÄÕ¾µãÉÏ£¬ÕâЩԪËؽ«ÔÚÿ¸öÒ³ÃæÉϳÊÏÖÏàͬµÄ²¼¾Ö¡¢ÄÚÈݺ͹¦ÄÜ£¬¶øÖ÷Ãæ°å£¨Í¨³£³ÆΪÄÚÈÝ´°¸ñ£©»áËæ×Åÿ¸öÊÓͼ¶ø±ä»¯¡£
Ò


Ïà¹ØÎĵµ£º

jspѧϰ±Ê¼Ç5

JSP2.0Öеıí´ïʽÓïÑÔ(EL±í´ïʽ)
ELÓï·¨
ELµÄÓï·¨ºÜ¼òµ¥£¬Ëû×î´óµÄÌصã¾ÍÊÇʹÓÃÉϺܷ½±ã
Àý£º
${sessionScope.user.sex}
ËùÓÐEL¶¼ÊÇÒÔ ${ ΪÆðʼ¡¢ÒÔ} Ϊ½áβµÄ¡£
ÉÏÊöEL·¶ÀýµÄÒâ˼ÊÇ£º´ÓSessionÈ¡µÃÓû§µÄÐÔ±ð¡£Èç¹ûʹÓÃ֮ǰJSP´úÂëµÄд·¨ÈçÏ£º
<%
  User user = (User)session.getAttribute("user");
& ......

JSPÖеļ¸ÖÖ°üº¬Ò³Ãæ·½·¨µÄÇø±ð

(1)include     ÔÚJSP±àÒë³ÉJavaÀàÎļþʱ£¬ÏȽ«includeÎļþÄÚÈݺϲ¢ºó£¬ÔÙ½øÐбàÒë
(2)jsp:include     ÔËÐÐʱºÏ²¢,»á½«ÔËÐÐʱµÄ½á¹û°üº¬½øÀ´
(3)c:import     ÔËÐÐʱºÏ²¢,»á½«ÔËÐÐʱµÄ½á¹û°üº¬½øÀ´
Òò´Ë£¬
£¨1£©ÀûÓÃinclude°üº¬µÄÒ³ÃæÖÐÈç¹û°üº¬Á˺ÍÔ­Ò ......

jspµÄ°Ë¸öÒþº¬¶ÔÏó

Ò»¡¢page ¶ÔÏó
    page¶ÔÏó´ú±íJSP±¾Éí£¬¸ü׼ȷµØ˵Ëü´ú±íJSP±»×ªÒëºóµÄServlet£¬Ëü¿ÉÒÔµ÷ÓÃServletÀàËù¶¨ÒåµÄ·½·¨¡£
   
¶þ¡¢config ¶ÔÏó
    config ¶ÔÏóÀï´æ·Å×ÅһЩServlet ³õʼµÄÊý¾Ý½á¹¹¡£
    config ¶ÔÏóʵÏÖÓÚjavax.servlet.ServletConfig ½Ó ......

JSPÄÚÖöÔÏó(9¸ö³£ÓõÄÄÚÖöÔÏó)

JSPÄÚÖöÔÏó(9¸ö³£ÓõÄÄÚÖöÔÏó)  
 1.request¶ÔÏó 
¿Í»§¶ËµÄÇëÇóÐÅÏ¢±»·â×°ÔÚrequest¶ÔÏóÖУ¬Í¨¹ýËü²ÅÄÜÁ˽⵽¿Í»§µÄÐèÇó£¬È»ºó×ö³öÏìÓ¦¡£ËüÊÇHttpServletRequestÀàµÄʵÀý¡£ 
ÐòºÅ ·½ ·¨ ˵ Ã÷ 
1 object getAttribute(String name) ·µ»ØÖ¸¶¨ÊôÐÔµÄÊôÐÔÖµ 
2 Enumeration getAttr ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ