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">
&
Ïà¹ØÎĵµ£º
ÓеÄÒ³ÃæÐèҪÿ´Îµã»÷½øÈ¥¶¼¶¯Ì¬¸üУ¬¶ø²»ÊǶÁÈ¡»º´æÖеÄÒ³Ãæ¡£
ÔÚJSPÖпÉÒÔÕâÑùʵÏÖ£º
<%
request.setCharacterEncoding("GBK");
response.addDateHeader("Expires",0);
response.setHeader("Pragma","no-cache");
response.setHeader("Cache-Control","no-cache");
%> ......
ÏÖÔÚÖ÷Á÷µÄÍøÕ¾¿ª·¢ÓïÑÔÎÞÍâºõasp¡¢php¡¢asp.net¡¢jspµÈ¡£
ÍøÒ³´Ó¿ªÊ¼¼òµ¥µÄhmtlµ½¸´ÔӵķþÎñÓïÑÔ£¬×ß¹ýÁË10¶à¸öÄêÍ·£¬¸÷ÖÖ¼¼Êõ²ã³ö²»Çµ¥¸öµÄÖ÷Á÷¼¼ÊõÒ²ÔÚ²»¶Ï·Ðµİ汾£¬ÏÖÔÚ·ÖÎöϸ÷ÖÖÓïÑÔµÄÇø±ð¡¢ÓÅÊÆ¡¢ÁÓÊÆ¡¢¿ª·¢×¢ÒâÊÂÏ
HTML:µ±È»ÕâÊÇÍøÒ³×î»ù±¾µÄÓïÑÔ,ÿһ¸ö·þÎñÆ÷ÓïÑÔ¶¼ÐèÒªËüµÄÖ§³Ö,Ҫѧϰ,Õâ¸ö¿Ï¶¨ÊÇ¿ª ......
×ܵÄÀ´½²£¬JavaSever PagesTM£¨JSP£©ºÍ ΢ÈíµÄActive Sever Pages£¨ASP£©ÔÚ¼¼Êõ·½ÃæÓÐÐí¶àÏàËÆÖ®´¦¡£Á½Õ߶¼ÊÇΪ»ùÓÚWEBÓ¦ÓÃʵÏÖ¶¯Ì¬½»»¥ÍøÒ³ÖÆ×÷ÌṩµÄ¼¼Êõ»·¾³Ö§³Ö¡£Í¬µÈ³Ì¶ÈÉÏÀ´½²£¬Á½Õ߶¼Äܹ»Îª³ÌÐò¿ª·¢ÈËÔ±ÌṩʵÏÖÓ¦ÓóÌÐòµÄ±àÖÆÓë×Ô´ø×é¼þÉè¼ÆÍøÒ³´ÓÂß¼ÉÏ·ÖÀëµÄ¼¼Êõ¡£¶øÇÒÁ½Õ߶¼Äܹ»Ìæ´úCGIʹÍøÕ¾½¨ÉèÓë·¢Õ¹±äµÄ½ÏΪ ......
GBK±àÂë
GBK±àÂëÊÇÖйúÖƶ©µÄ¡¢µÈͬÓÚUCSµÄеÄÖÐÎıàÂëÀ©Õ¹¹ú¼Ò±ê×¼¡£GBK¹¤×÷С×éÓÚ1995Äê10Ô£¬Í¬Äê12ÔÂÍê³ÉGBK¹æ·¶¡£¸Ã±àÂë±ê×¼¼æÈÝGB2312£¬¹²ÊÕ¼ºº×Ö21003¸ö¡¢·ûºÅ883¸ö£¬²¢Ìṩ1894¸öÔì×ÖÂë룬¼ò¡¢·±Ìå×ÖÈÚÓÚÒ»¿â¡£
UTF-8±àÂë
UTF-8±àÂë¿ÉÒÔͨ¹ýÆÁ±ÎλºÍÒÆλ²Ù×÷¿ìËÙ¶Áд¡£×Ö·û´®±È½Ïʱstrcmp()ºÍ
wcscmp()µÄ· ......
jsp request session
µÈ¶ÔÏó
Ïê½â
תÕß×¢£º´ËÎÄ×ܽá½ÏΪÏêϸ£¬ÖµµÃ²Î¿¼¡£µ«²¿·ÖÄÚÈݾ¹ýÕûÀí£¬ÒÔÏÂÊÇÕýÎÄ¡£
1.request
¶ÔÏó
ÕâÁ½¸ö¶ÔÏóÊÇASPËùÌṩµÄÄÚÖöÔÏóÖÐ×î³£ÓõÄÁ½¸ö¡£ÔÚä¯ÀÀÆ÷£¨»òÆäËûÓû§´úÀí£©ºÍWeb·þÎñÆ÷Ö®¼ä£¬ÇëÇóÓëÏìÓ¦Öз¢ÉúµÄÐÅÏ¢½»Á÷¿ÉÒÔͨ¹ýASPÖеÄÁ½¸öÄÚÖöÔÏóÀ´½øÐÐ ......