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

JSP

 1  forward ºÍredirectµÄÇø±ð
     Ò»¾ä»°£¬×ª·¢ÊÇ·þÎñÆ÷ÐÐΪ£¬Öض¨ÏòÊÇ¿Í»§¶ËÐÐΪ¡£ÎªÊ²Ã´ÕâÑù˵ÄØ£¬Õâ¾ÍÒª¿´Á½¸ö¶¯×÷µÄ¹¤×÷Á÷³Ì£º
ת·¢¹ý³Ì£º¿Í»§ä¯ÀÀÆ÷·¢ËÍhttpÇëÇó----¡·web·þÎñÆ÷½ÓÊÜ´ËÇëÇó--¡·µ÷ÓÃÄÚ²¿µÄÒ»¸ö·½·¨ÔÚÈÝÆ÷ÄÚ²¿Íê³ÉÇëÇó´¦ÀíºÍת·¢¶¯×÷----¡·½«Ä¿±ê×ÊÔ´·¢Ë͸ø¿Í»§£»ÔÚÕâÀת·¢µÄ·¾¶±ØÐëÊÇͬһ¸öwebÈÝÆ÷ϵÄurl£¬Æä²»ÄÜתÏòµ½ÆäËûµÄweb·¾¶ÉÏÈ¥£¬Öм䴫µÝµÄÊÇ×Ô¼ºµÄÈÝÆ÷ÄÚµÄrequest¡£ÔÚ¿Í»§ä¯ÀÀÆ÷·¾¶À¸ÏÔʾµÄÈÔÈ»ÊÇÆäµÚÒ»´Î·ÃÎʵÄ·¾¶£¬Ò²¾ÍÊÇ˵¿Í»§ÊǸоõ²»µ½·þÎñÆ÷×öÁËת·¢µÄ¡£×ª·¢ÐÐΪÊÇä¯ÀÀÆ÷Ö»×öÁËÒ»´Î·ÃÎÊÇëÇó¡£
Öض¨Ïò¹ý³Ì£º¿Í»§ä¯ÀÀÆ÷·¢ËÍhttpÇëÇó----¡·web·þÎñÆ÷½ÓÊܺó·¢ËÍ302״̬ÂëÏìÓ¦¼°¶ÔӦеÄlocation¸ø¿Í»§ä¯ÀÀÆ÷--¡·¿Í»§ä¯ÀÀÆ÷·¢ÏÖÊÇ302ÏìÓ¦£¬Ôò×Ô¶¯ÔÙ·¢ËÍÒ»¸öеÄhttpÇëÇó£¬ÇëÇóurlÊÇеÄlocationµØÖ·----¡··þÎñÆ÷¸ù¾Ý´ËÇëÇóÑ°ÕÒ×ÊÔ´²¢·¢Ë͸ø¿Í»§¡£ÔÚÕâÀïlocation¿ÉÒÔÖض¨Ïòµ½ÈÎÒâURL£¬¼ÈÈ»ÊÇä¯ÀÀÆ÷ÖØз¢³öÁËÇëÇó£¬Ôò¾ÍûÓÐʲôrequest´«µÝµÄ¸ÅÄîÁË¡£ÔÚ¿Í»§ä¯ÀÀÆ÷·¾¶À¸ÏÔʾµÄÊÇÆäÖض¨ÏòµÄ·¾¶£¬¿Í»§¿ÉÒԹ۲쵽µØÖ·µÄ±ä»¯µÄ¡£Öض¨ÏòÐÐΪÊÇä¯ÀÀÆ÷×öÁËÖÁÉÙÁ½´ÎµÄ·ÃÎÊÇëÇóµÄ¡£
      £¨1£©´ÓµØÖ·À¸ÏÔʾÀ´Ëµ
forwardÊÇ·þÎñÆ÷ÇëÇó×ÊÔ´,·þÎñÆ÷Ö±½Ó·ÃÎÊÄ¿±êµØÖ·µÄURL,°ÑÄǸöURLµÄÏìÓ¦ÄÚÈݶÁÈ¡¹ýÀ´,È»ºó°ÑÕâЩÄÚÈÝÔÙ·¢¸øä¯ÀÀÆ÷.ä¯ÀÀÆ÷¸ù±¾²»ÖªµÀ·þÎñÆ÷·¢Ë͵ÄÄÚÈÝ´ÓÄÄÀïÀ´µÄ,ËùÒÔËüµÄµØÖ·À¸»¹ÊÇÔ­À´µÄµØÖ·.
redirectÊÇ·þÎñ¶Ë¸ù¾ÝÂß¼­,·¢ËÍÒ»¸ö״̬Âë,¸æËßä¯ÀÀÆ÷ÖØÐÂÈ¥ÇëÇóÄǸöµØÖ·.ËùÒÔµØÖ·À¸ÏÔʾµÄÊÇеÄURL.ËùÒÔredirectµÈÓÚ¿Í»§¶ËÏò·þÎñÆ÷¶Ë·¢³öÁ½´Îrequest£¬Í¬Ê±Ò²½ÓÊÜÁ½´Îresponse¡£
      £¨2£©´ÓÊý¾Ý¹²ÏíÀ´Ëµ
forward:ת·¢Ò³ÃæºÍת·¢µ½µÄÒ³Ãæ¿ÉÒÔ¹²ÏírequestÀïÃæµÄÊý¾Ý.
redirect:²»Äܹ²ÏíÊý¾Ý.
redirect²»½ö¿ÉÒÔÖض¨Ïòµ½µ±Ç°Ó¦ÓóÌÐòµÄÆäËû×ÊÔ´,»¹¿ÉÒÔÖض¨Ïòµ½Í¬Ò»¸öÕ¾µãÉϵÄÆäËûÓ¦ÓóÌÐòÖеÄ×ÊÔ´,ÉõÖÁÊÇʹÓþø¶ÔURLÖض¨Ïòµ½ÆäËûÕ¾µãµÄ×ÊÔ´.
forward,·½·¨Ö»ÄÜÔÚͬһ¸öWebÓ¦ÓóÌÐòÄÚµÄ×ÊÔ´Ö®¼äת·¢ÇëÇó.forward ÊÇ·þÎñÆ÷ÄÚ²¿µÄÒ»ÖÖ²Ù×÷.
redirect ÊÇ·þÎñÆ÷֪ͨ¿Í»§¶Ë,Èÿͻ§¶ËÖØз¢ÆðÇëÇó.
      £¨3£©´ÓÔËÓõط½À´Ëµ
forward:Ò»°ãÓÃÓÚÓû§µÇ½µÄʱºò,¸ù¾Ý½Çɫת·¢µ½ÏàÓ¦µÄÄ£¿é.
redirect:Ò»°ãÓÃÓÚÓû§×¢ÏúµÇ½ʱ·µ»ØÖ÷Ò³ÃæºÍÌøתµ½ÆäËüµÄÍøÕ¾µÈ.
¡¡¡¡£¨£´£©´ÓЧÂÊÀ´Ëµ


Ïà¹ØÎĵµ£º

С±à¸ÅÊöJSP¼¼Êõ

 
°´Õսű¾ÓïÑÔÊÇ·þÎñÓÚijһ¸ö×ÓϵͳµÄÓïÑÔÕâÖÖÂÛÊö£¬ JSPÓ¦µ±±»¿´×÷ÊÇÒ»Öֽű¾ÓïÑÔ£¬È»¶ø£¬×÷ΪһÖֽű¾ÓïÑÔ£¬ JSPÓÖÏԵùýÓÚÇ¿´óÁË£¬ÔÚJSPÖм¸ºõ¿ÉÒÔʹÓÃÈ«²¿µÄJavaÀà¡£
×÷ΪһÖÖ»ùÓÚÎı¾µÄ¡¢ÒÔÏÔʾΪÖÐÐĵĿª·¢¼¼Êõ£¬JSPÌṩÁËJava Servlet µÄËùÓкô¦£¬²¢ÇÒ£¬µ±ÓëÒ»¸öJavaBeans Àà½áºÏÔÚÒ»Æðʱ£¬ÌṩÁËÒ»ÖÖʹÄÚÈ ......

jbossƽ̨ÏÂjspÁ¬½Ósql2005ºÍsql2000

1¡¢ÅäÖÃjava»·¾³£¬MyEclipse7.0¡£ÅäÖÃjboss5.0£¬Õ¹¿ªÑ¡ÔñjdkΪÒÑ°²×°µÄjdk·¾¶¡£
2¡¢°²×°2005ºÍsql2000£¬×°2000ʱҪװsp4.Çý¶¯Ñ¡Ôñjdbc2.0¡£ÔÙ×°2000ʱʵÀýÃû×Ô¼ºÊäÈëÒ»¸ö¡£ÕâÀïµÄÎÊÌâ¾ÍÊǵǼÃûºÍÃÜÂëµÄÉèÖã¬ÓÒ»÷“SQL   Server×é”ϵÄʵÀýÃû£¨Windows   NT)"µÄ“ÊôÐÔ”£¬ÔÚµ¯³öµÄ¶Ô»°¿ò ......

JSPƬ¶Î

ʹÓÃjspf
ÔÚ¿ª·¢ÖÐдjspÒ³Ãæʱ£¬Í¨³£¶¼ÒªÍ¨¹ýÈçÏ·½Ê½ÔÚjspÎļþÍ·²¿ÒýÈëÎÒÃÇÐèÒªµÄ±êÇ©¿â£¬È磺jspºËÐıêÇ©¿âJSTL£¬Struts ÖеÄ×Ô¶¨Òå±êÇ©£¬Ê±¶ø»¹ÓÐÎÒÃÇ×Ô¼ºÐ´µÄ×Ô¶¨Òå±êÇ©£º
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefi ......

JSP·ÖÒ³Ö®¼Ù·ÖÒ³¼°MVCʵÏÖ

 MVCÊÇÓÉÄ£ÐͲ㣬ÊÓͼ²ã£¬¿ØÖƲã×é³É£¬MVCÌá¸ßÁË¿ª·¢Ð§ÂÊ£¬±ãÓÚά»¤
·ÖÒ³ÊÇWeb¿ª·¢ÖеÄÒ»¸öÖØÒªµÄ¹¦ÄÜ£¬ÄÇÔõÑùʵÏÖ·ÖÒ³ÄØ£¿£¿£¿
¼Ù·ÖÒ³ÊÇÖ¸²éѯ³öËùÓеÄÊý¾Ý£¬Ö»ÏÔʾÐèÒªµÄÊý¾Ý£¬ËüÍêÈ«ÓɳÌÐòʵÏÖ£¬¿ª·¢Ð§Âʲ»¸ß£¬µ«ÈÝÒ×ʵÏÖ
´úÂëÈçÏÂ:
Ò».Ä£ÐͲã
UserInfo(JavaBeanµÄʵÏÖ£¬´«µÝÊý¾Ý£©
package com.feng.test;
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ