JSPÖÐʹÓÃIncludeÓëJSP£ºIncludeµÄÇø±ð
ÎÒÃǶ¼ÖªµÀÔÚjspÖÐincludeÓÐÁ½ÖÖÐÎʽ,·Ö±ðÊÇ
< %@ include file=” ”% >
< jsp:include page=” ” flush=”true”/ >
Ç°ÕßÊÇÖ¸ÁîÔªËØ¡¢ºóÕßÊÇÐÐΪԪËØ¡£
¾ßÌåËüÃǽ«Ôںδ¦Óã¿ÈçºÎÓü°ËüÃÇÓÐʲôÇø±ð£¿ÕâÓ¦¸ÃÊǺܶàÈË¿´µ½Ëü¶¼»áÏëµ½µÄÎÊÌâ¡£ÏÂÃæÒ»ÆðÀ´¿´¿´°É¡£
ͨ³£µ±Ó¦ÓóÌÐòÖÐËùÓеÄÒ³ÃæµÄijЩ²¿·Ö£¨ÀýÈç±êÌâ¡¢Ò³½ÅºÍµ¼º½À¸£©¶¼ÏàͬµÄʱºò£¬ÎÒÃǾͿÉÒÔ¿¼ÂÇÓÃinclude¡£¾ßÌåÔÚÄÄЩʱºòÓÃ< % @ include file=” ”% >£¬ÄÄЩʱºòÓÃ< jsp:include page=” ” flush=”true”/ >. ÕâÖÖÐÎʽ¡£Ê×ÏÈÒªÃ÷°×µÄÊÇËüÃÇÖ®¼äµÄÇø±ð¡£Ö»ÓÐÁ˽âÁËËüÃÇÓ÷¨µÄ²»Í¬²ÅÀí½â¸ÃÔÚºÎʱȥÓÃÒÔ¼°ÈçºÎÑ¡Ôñ¡£
< %@ include file=” ”% >,jspµÄincludeÖ¸ÁîÔªËضÁÈëÖ¸¶¨Ò³ÃæµÄÄÚÈÝ¡£²¢°ÑÕâЩÄÚÈݺÍÔÀ´µÄÒ³ÃæÈںϵ½Ò»Æð¡££¨Õâ¸ö¹ý³ÌÊÇÔÚ·Òë½×¶Î:Ò²¾ÍÊÇjsp±»×ª»¯³ÉservletµÄ½×¶Î½øÐеġ£
ÕâÀï¶Ô·Òë½×¶Î½øÐÐÒ»ÏÂ˵Ã÷:ÎÒÃÇÖªµÀ£¬jspÒ³Ãæ²»ÄÜÔ·â²»¶¯µØ±»´«Ë͸øä¯ÀÀÆ÷£¬ËùÓеÄjspÔªËض¼±ØÐëÊ×ÏÈÓÉ·þÎñÆ÷½øÐд¦Àí¡£ÕâÊÇͨ¹ý½«jspÒ³Ãæת´ï»¯³Éservlet£¬È»ºóÖ´ÐÐÕâ¸öservletÀ´Íê³ÉµÄ¡£·þÎñÆ÷ÐèÒªÒ»¸öjspÈÝÆ÷À´´¦ÀíjspÒ³Ãæ¡£jspÈÝÆ÷ͨ³£ÒÔservletµÄÐÎʽÀ´ÊµÏÖ£¬Õâ¸öservlet¾¹ýÅäÖ㬿ÉÒÔ´¦Àí¶ÔjspÒ³ÃæµÄËùÓÐÇëÇó¡£
JspÈÝÆ÷¸ºÔð½«jspÒ³Ãæת»¯³Éservlet£¨³ÆΪjspÒ³ÃæʵÏÖÀà?JSP Page implementation class£©,²¢±àÒëÕâ¸öservlet¡£ÕâÁ½²½¾Í¹¹³ÉÁË·Òë½×¶Î.
ÓÉ´ËÎÒÃǾͻáÖªµÀ£ºjspÒ³ÃæÊÇ°ÑincludeÖ¸ÁîÔªËØËùÖ¸¶¨µÄÒ³ÃæµÄʵ¼ÊÄÚÈÝ£¨Ò²¾ÍÊÇ´úÂë¶Î£©¼ÓÈëµ½ÒýÈëËüµÄjspÒ³ÃæÖÐ,ºÏ³ÉÒ»¸öÎļþºó±»jspÈÝÆ÷½«Ëüת»¯³Éservlet¡£¿ÉÒÔ¿´µ½Õâʱ»á²úÉúÒ»¸öÁÙʱclassÎļþºÍÒ»¸öjavaÎļþ¡£ÏÂÃæ¾Ù¸öÀý×Ó¡£
·þÎñÆ÷ÓÃtomcat£¬ÒýÈëÒ³ÃæµÄjspÎļþ½Ðtest.jsp¡£±»ÒýÈëµÄÒ³Ãæ½Ðdate.jsp.Õâ¸öjspÎļþÀï´æ·ÅµÄÊÇÒ»¸öÓйØʱ¼äµÄjsp´úÂë,µ±Ç°µÄÉÏÏÂÎĸùÉèΪtest
//======date.jspµÄÔ´Îļþ=====//
<%@ page language=”java” contentType="text/html;charset=gb2312"%>
<%
java.util.Date date=new java.util.Date();
String date_cn ="";
String dateStr = "";
switch(date.getDay())
{
case 0:date_cn ="ÈÕ"; break;
case 1:date_cn ="Ò»"; break;
case 2:date_cn ="¶þ"; break;
case 3:date_cn ="Èý"; break;
case 4:date_cn ="ËÄ"; break;
case 5:dat
Ïà¹ØÎĵµ£º
²»Ëµ·Ï»°ÁË£¬¿´ÏÂÃæµÄÀý×Ó°É(ÀûÓÃstructsʵÏÖ£©£º
ÔÚWEB£INFÏÂÓÐÁ½¸öÒ³Ã棺 a.jsp ºÍ b.jsp £¬ ÏÖÔÚҪʵÏÖ´Óa.jspÁ¬½Óµ½b.jsp
ÔÚa.jspÖУº
<html:link action= ......
ÔÚWEBÓ¦ÓÃÖÐ,Èç¹ûʹÓÃjsp×÷Ϊview²ãµÄÏÔʾģ°å,¶¼»á±»¿Õ¸ñ/¿Õ»»ÐÐÎÊÌâËùÀ§ÈÅ.
Õâ¸öÎÊÌâµ±ÄêÒ²À§ÈÅÁËÎұȽϳ¤µÄʱ¼ä.ÒòΪÔÚjspÄÚʹÓõÄEL±êÇ©ºÍÆäËû±êǩʱ,»á²úÉú´óÁ¿µÄ¿Õ¸ñºÍ»»Ðзû.ÀýÈç:
------- start ----------
<c:choose>
<c:when test="${fn:length(mainPageList)>1&}&q ......
1. RequestDispatcher.forward()
ÊÇÔÚ·þÎñÆ÷¶ËÆð×÷ÓÃ,µ±Ê¹ÓÃforward()ʱ,Servlet engine´«µÝHTTPÇëÇó´Óµ±Ç°µÄServlet or JSPµ½ÁíÍâÒ»¸öServlet,JSP »òÆÕͨHTMLÎļþ,Ò²¼´ÄãµÄformÌá½»ÖÁa.jsp,ÔÚa.jspÓõ½ÁËforward()Öض¨ÏòÖÁb.jsp,´ËʱformÌá½»µÄËùÓÐÐÅÏ¢ÔÚ b.jsp¶¼¿ÉÒÔ»ñµÃ,²ÎÊý×Ô¶¯´«µÝ. µ«forward()ÎÞ·¨Öض¨ÏòÖÁÓÐframeµ ......
servlet APIµÄ2.3°æ±¾ÖÐ×îÖØÒªµÄÒ»¸öй¦ÄܾÍÊÇÄܹ»ÎªservletºÍJSPÒ³Ã涨Òå¹ýÂËÆ÷¡£¹ýÂËÆ÷ÌṩÁËijЩÔçÆÚ·þÎñÆ÷ËùÖ§³ÖµÄ·Ç±ê×¼
“servletÁ´½Ó”µÄÒ»ÖÖ¹¦ÄÜÇ¿´óÇÒ±ê×¼µÄÌæ´úÆ·¡£
¹ýÂËÆ÷ÊÇÒ»¸ö³ÌÐò£¬ËüÏÈÓÚÓëÖ®Ïà¹ØµÄservlet»òJSPÒ³ÃæÔËÐÐÔÚ·þÎñÆ÷ÉÏ¡£¹ýÂËÆ÷¿É
¸½¼Óµ½Ò»¸ö»ò¶à¸öservlet»òJSPÒ³ÃæÉÏ£¬²¢ÇÒ¿É ......
½¨Á¢×ÔÒѵÄwebĿ¼
¿ÉÒÔ½«JSPÒ³Ãæ³ÌÐò²¿ÊðÔÚTomcat·þÎñÆ÷µÄĬÈÏwebĿ¼Ï£¬Ò²¿ÉÒÔ²¿ÊðÔÚ×ÔÒÑ´´½¨µÄwebĿ¼Ï¡£ÏÂÃæÊÇ´´½¨webĿ¼µÄ²½Ö裺
1)£®ÔÚ·þÎñÆ÷ÉÏ´´½¨×ÔÒѵÄĿ¼
È磬´´½¨Ò»Ä¿Â¼£º E:\test\10
2)£®ÅäÖÃwebĿ¼
ÓüÇʱ¾´ò¿ª \Tomcat 5.0\confĿ¼ÏµÄÎļþs ......