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

JSPÒ³ÃæÌøת´óÈ«

JSPÒ³ÃæÌøת´óÈ«
JSPÖеÄÌøת£º
(1). forward()·½·¨
    ʹÓõ½javax.servlet.RequestDispatcherÀà
    RequestDispatcher rd = getServletContext().getRequestDispatcher("url");
    rd.forward(requestVar,requestVar); //´«µÝservletµÄÈë¿Ú²ÎÊý
    /*forwardº¯ÊýÒѾ­°ÑÔ­Ò³ÃæµÄrequest,response¶ÔÏó´«ÈëеÄÒ³Ã棬Òò´ËÕâоÉÒ³ÃæÓµÓÐÏàͬµÄrequest,response¶ÔÏó¡£request.getparameter("var")¾Í¿ÉÒԵõ½ÏàÓ¦µÄÖµ.*/
    /*forward()ÊÇÖ±½ÓÔÚserver×öµÄ£¬ä¯ÀÀÆ÷²¢²»ÖªµÀ£¬Ò²²»ºÍä¯ÀÀÆ÷´ò½»µÀ£¬ä¯ÀÀÆ÷µÄµØÖ·²»±ä»¯¡£*/
    ¼´£º
    getServletContext().getRequestDispatcher("url").forward(requestVar,responseVar);
    ·þÎñÆ÷¶ËServlet½øÐÐתÏòµÄ4ÖÖ·½·¨£º
    1.ServletContextµÄgetRequestDispatcher()    
    2.ServletContextµÄgetNamedDispatcher()   
    3.ServletRequestµÄgetRequestDispatcher()   
    4.ServletResponseµÄsendredirect()½øÐÐתÏò¡£
    forward·½·¨£¬ÒòΪÕâЩÕâÑù±È½Ï¸ßЧ¡£Ö»ÓÐÔÚforward·½·¨²»ÄÜʹÓÃʱ£¬ÔÙʹÓÃservletresponseµÄsendredirect()·½·¨¡£
(2).response.sendRedirect(url);  
    ÆäʵÊÇÏòä¯ÀÀÆ÷·¢ËÍÒ»¸öÌØÊâµÄHeader£¬È»ºóÓÉä¯ÀÀÆ÷À´×öתÏò£¬×ªµ½Ö¸¶¨µÄÒ³Ã棬ËùÒÔÓÃsendRedirectʱ£¬ä¯ÀÀÆ÷µÄµØÖ·À¸ÉÏ¿ÉÒÔ¿´µ½µØÖ·µÄ±ä»¯¡£ÐÂÒ³Ãæ²»ÄÜ´¦Àí¾ÉÒ³ÃæµÄpagecontext(request,response,...)¶ÔÏó.
    ÔÚresponse.sendRedirectÖ®ºó£¬Ó¦¸Ã½ô¸úÒ»¾äreturn;
(3).HTMLÓïÑÔµÄ×Ô¶¯Ìøת
    <html>
    <head>
        <meta http-equiv="refresh" content="0;url="http://www.baidu.com">
        0Êǵȴýʱ¼ä£¬Èç¹ûÉèÖÃΪ5±íʾµÈ´ý5sºó¿ªÊ¼Ìøת
    </head>
    …………
(4).JavaScriptÌøת
A:    <script languate="javascript">
&n


Ïà¹ØÎĵµ£º

jspÒ³ÃæʹÓÃstruts2µÄproperty±êÇ©Êä³öÎÊÌâ

jspÒ³ÃæʹÓÃstruts2µÄproperty±êÇ©Êä³öÈçÏÂÄÚÈÝ
<s:property value="detailinfo"/>  ÆäÖУ¬detailinfo="<strong>abc</strong>"£»
ºÃÏñûÊ£¬ÎÊÌâ³öÏÖÁË£¬ÔÚjspÒ³ÃæÉÏÏÔʾ³öÁË<strong>abc</strong>
Ò»¿´Ò³ÃæÔ´Â룬·¢ÏÖ£¬Ô´´úÂëÖÐÒѾ­±ä³ÉÁË
&lt; strong&a ......

jsp½¨Õ¾Àú³Ì

      Á½ÄêÇ°£¬ÔøÓÐһλǰ±²¶ÔÎÒ˵¹ý£º¿ª·¢Ò»¸öÊôÓÚÄã×Ô¼ºµÄÍøÕ¾£¬È»ºóÿÌ컨һµã¿ÕÏеÄʱ¼äÈ¥¾­ÓªÒ»Ï£¬ÖÕÓÐÒ»Ì죬Äã»á·¢¾õËüÊǷdz£ÓÐÓõġ£¸Õ¿ªÊ¼µÄʱºò£¬ÎÒûÓаÑÕâЩ»°·ÅÔÚÐÄÉÏ£¬ÂýÂýµØ£¬ÎҲŷ¢¾õÕâλǰ±²ËµµÄ»°ÊǺÜÓеÀÀíµÄ¡£¼ÙÉèÁ½ÄêÇ°¿ªÊ¼¾­ÓªÒ»¸öÍøÕ¾£¬Í¨¹ýÕâÁ½ÄêµÄÍƹãºÍÔËÓª£¬Ëµ²»¶¨µ½Ï ......

JspÉú³É¾²Ì¬Ò³Ãæ

ΪÁ˼õÇá·þÎñÆ÷ѹÁ¦£¬½«Ô­À´µÄÎÄÕ¹ÜÀíϵͳÓÉJSPÎļþµÄ´ÓÊý¾Ý¿âÖÐÈ¡Êý¾ÝÏÔʾ¸ÄΪÓÉjspÉú³É¾²Ì¬htmlÎļþºóÖ±½Ó·ÃÎÊhtmlÎļþ¡£Ê×ÏÈÓ¦´´½¨Ò»¸öÄ£°åÎļþ£¬ÎļþÃûºÍÎļþºó׺¿ÉÒÔËæÒ⣬µ«ÎÒÒ»°ã³£ÓõĻ¹ÊÇ *.template £¬Òò´Ë£¬ÕâÀï¾ÍÒÔ template.template ΪÀý( ½«Ä£°åÎļþ·ÅÈë /WEB-INF/templates/ Îļþ¼ÐÏ )£ºÏÂÃæÊÇÒ»¸ö¼òµ¥µÄ ......

jsp ÖÐÎÄÂÒÂë½â¾ö´óÈ«

Ò»¡¢JSPÒ³ÃæÏÔʾÂÒÂë
¶þ¡¢±íµ¥Ìá½»ÖÐÎÄʱ³öÏÖÂÒÂë
Èý¡¢Êý¾Ý¿âÁ¬½Ó
´ó¼ÒÔÚJSPµÄ¿ª·¢¹ý³ÌÖУ¬¾­³£³öÏÖÖÐÎÄÂÒÂëµÄÎÊÌ⣬¿ÉÄÜÒ»ÖÁÀ§ÈÅ×ÅÄú£¬ÎÒÏÖÔÚ°ÑÎÒÔÚJSP¿ª·¢ÖÐÓöµ½
µÄÖÐÎÄÂÒÂëµÄÎÊÌâ¼°½â¾ö°ì·¨Ð´³öÀ´¹©´ó¼Ò²Î¿¼¡£
Ò»¡¢JSPÒ³ÃæÏÔʾÂÒÂë
ÏÂÃæµÄÏÔʾҳÃæ(display.jsp)¾Í³öÏÖÂÒÂ룺
<html>
<head>
<tit ......

ÌáÉýJSPÓ¦ÓóÌÐòµÄÆß´ó¾øÕÐ


Äãʱ³£±»¿Í»§±§Ô¹JSPÒ³ÃæÏìÓ¦ËٶȺÜÂýÂð£¿ÄãÏë¹ýµ±¿Í»§·ÃÎÊ´ÎÊý¾çÔöʱ£¬ÄãµÄWEBÓ¦ÓÃÄܳÐÊÜÈÕÒæÔö¼ÓµÄ·ÃÎÊÁ¿Âð£¿
      ±¾ÎĽ²ÊöÁ˵÷ÕûJSPºÍservletµÄһЩ·Ç³£ÊµÓõķ½·¨£¬Ëü¿ÉʹÄãµÄservletºÍJSPÒ³ÃæÏìÓ¦¸ü¿ì£¬À©Õ¹ÐÔ¸üÇ¿¡£¶øÇÒÔÚÓû§ÊýÔö¼ÓµÄÇé¿öÏ£¬ÏµÍ³¸ºÔØ»á³ÊÏÖ³öƽ»¬Éϳ¤µÄÇ÷ÊÆ¡£ÔÚ±¾ÎÄÖ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ