JSP/Servletת·¢ÓëÖض¨ÏòµÄÇø±ð
JSP/Servletת·¢ÓëÖض¨ÏòµÄÇø±ð
¾¡¹ÜHttpServletResponse.sendRedirect ·½·¨ºÍRequestDispatcher.forward ·½·¨¶¼¿ÉÒÔÈÃä¯ÀÀÆ÷»ñµÃÁíÍâÒ»¸öURLËùÖ¸ÏòµÄ×ÊÔ´£¬µ«Á½ÕßµÄÄÚ²¿ÔËÐлúÖÆÓÐןܴóµÄÇø±ð¡£
¡¡¡¡ÏÂÃæÊÇHttpServletResponse.sendRedirect ·½·¨ÊµÏÖµÄÇëÇóÖض¨ÏòÓëRequestDispatcher.forward ·½·¨ÊµÏÖµÄÇëÇóת·¢µÄ×ܽá±È½Ï£º
£¨1£©RequestDispatcher.forward ·½·¨Ö»Äܽ«ÇëÇóת·¢¸øͬһ¸öWEBÓ¦ÓÃÖеÄ×é¼þ£»¶øHttpServletResponse.sendRedirect ·½·¨²»½ö¿ÉÒÔÖض¨Ïòµ½µ±Ç°Ó¦ÓóÌÐòÖеÄÆäËû×ÊÔ´£¬»¹¿ÉÒÔÖض¨Ïòµ½Í¬Ò»¸öÕ¾µãÉϵÄÆäËûÓ¦ÓóÌÐòÖеÄ×ÊÔ´£¬ÉõÖÁÊÇʹÓþø¶ÔURLÖض¨Ïòµ½ÆäËûÕ¾µãµÄ×ÊÔ´¡£Èç¹û´«µÝ¸øHttpServletResponse.sendRedirect ·½·¨µÄÏà¶ÔURLÒÔ“/”¿ªÍ·£¬ËüÊÇÏà¶ÔÓÚÕû¸öWEBÕ¾µãµÄ¸ùĿ¼£»Èç¹û´´½¨RequestDispatcher ¶ÔÏóʱָ¶¨µÄÏà¶ÔURLÒÔ“/”¿ªÍ·£¬ËüÊÇÏà¶ÔÓÚµ±Ç°WEBÓ¦ÓóÌÐòµÄ¸ùĿ¼¡£
£¨2£©µ÷ÓÃHttpServletResponse.sendRedirect ·½·¨Öض¨ÏòµÄ·ÃÎʹý³Ì½áÊøºó£¬ä¯ÀÀÆ÷µØÖ·À¸ÖÐÏÔʾµÄURL»á·¢Éú¸Ä±ä£¬ÓɳõʼµÄURLµØÖ·±ä³ÉÖض¨ÏòµÄÄ¿±êURL£»¶øµ÷ÓÃRequestDispatcher.forward ·½·¨µÄÇëÇóת·¢¹ý³Ì½áÊøºó£¬ä¯ÀÀÆ÷µØÖ·À¸±£³Ö³õʼµÄURLµØÖ·²»±ä¡£
£¨3£©HttpServletResponse.sendRedirect ·½·¨¶Ôä¯ÀÀÆ÷µÄÇëÇóÖ±½Ó×÷³öÏìÓ¦£¬ÏìÓ¦µÄ½á¹û¾ÍÊǸæËßä¯ÀÀÆ÷È¥ÖØз¢³ö¶ÔÁíÍâÒ»¸öURLµÄ·ÃÎÊÇëÇó¡£
¡¡¡¡¾Ù¸öÀý×Ó£ºÖض¨Ïò¹ý³ÌºÃ±ÈÓиö´ÂºÅ½Ð“ä¯ÀÀÆ÷”µÄÈËдÐÅÕÒÕÅÈý½èÇ®£¬ÕÅÈý»ØÐÅ˵ûÓÐÇ®£¬ÈÓä¯ÀÀÆ÷”È¥ÕÒÀîËĽ裬²¢½«ÀîËÄÏÖÔÚµÄͨÐŵØÖ·¸æË߸øÁË“ä¯ÀÀÆ÷”¡£ÓÚÊÇ£¬“ä¯ÀÀÆ÷”ÓÖ°´ÕÅÈýÌṩͨÐŵØÖ·¸øÀîËÄдÐŽèÇ®£¬ÀîËÄÊÕµ½Ðźó¾Í°ÑÇ®»ã¸øÁË“ä¯ÀÀÆ÷”¡£¿É¼û£¬“ä¯ÀÀÆ÷”Ò»¹²·¢³öÁËÁ½·âÐźÍÊÕµ½ÁËÁ½´Î»Ø¸´£¬“ä¯ÀÀÆ÷”Ò²ÖªµÀËû½èµ½µÄÇ®³ö×ÔÀîËÄÖ®ÊÖ¡£
¡¡¡¡RequestDispatcher.forward ·½·¨ÔÚ·þÎñÆ÷¶ËÄÚ²¿½«ÇëÇóת·¢¸øÁíÍâÒ»¸ö×ÊÔ´£¬ä¯ÀÀÆ÷Ö»ÖªµÀ·¢³öÁËÇëÇ󲢵õ½ÁËÏìÓ¦½á¹û£¬²¢²»ÖªµÀÔÚ·þÎñÆ÷³ÌÐòÄÚ²¿·¢ÉúÁËת·¢ÐÐΪ¡£Õâ¸ö¹ý³ÌºÃ±È´ÂºÅ½Ð“ä¯ÀÀÆ÷”µÄÈËдÐÅÕÒÕÅÈý½èÇ®£¬ÕÅÈýûÓÐÇ®£¬ÓÚÊÇÕÅÈýÕÒÀîËĽèÁËһЩǮ£¬ÉõÖÁ»¹¿ÉÒÔ¼ÓÉÏ×Ô¼ºµÄһЩǮ£¬È»ºóÔÙ½«ÕâЩǮ»ã¸øÁË“ä¯ÀÀÆ÷”¡£¿É¼û£¬“ä¯ÀÀÆ÷”Ö»·¢³öÁËÒ»·âÐźÍÊÕµ½ÁËÒ»´Î»Ø¸´£¬ËûÖ»ÖªµÀ´ÓÕÅÈýÄÇÀï½èµ½ÁË
Ïà¹ØÎĵµ£º
²Ù×÷·½·¨£º windows------preferences----------ËÑË÷ html----------ÕÒµ½ html SourceÕâÏî---------
ÕÒµ½ content assist (¼ûÏÂͼ)------Prompt when these¡£¡£¡£¡£ºóÃæÓиöÊäÈë¿ò£¨ÀïÃæÓиöСÓںţ©½ô¸ú СÓںźóÃæÊäÈëÒ»¸ö ¿Õ¸ñ¼ü £¬-----------apply----------ok¡£
ÔÚhtmlÖбà¼Ê ......
request request±íʾHttpServletRequest¶ÔÏó¡£Ëü°üº¬ÁËÓйØä¯ÀÀÆ÷ÇëÇóµÄÐÅÏ¢£¬²¢ÇÒÌṩÁ˼¸¸öÓÃÓÚ»ñÈ¡cookie, header, ºÍsessionÊý¾ÝµÄÓÐÓõķ½·¨¡£
response response±íʾHttpServletResponse¶ÔÏ󣬲¢ÌṩÁ˼¸¸öÓÃÓÚÉèÖÃËÍ»Ø ä¯ÀÀÆ÷µÄÏìÓ¦µÄ·½·¨£¨Èçcookies,Í·ÐÅÏ¢µÈ£©
out out ¶ÔÏóÊÇjavax.jsp.JspWriterµÄÒ»¸öʵÀý£¬ ......
404´íÎóÊÇʲôʱºò²úÉúµÄÄØ£¿µ±ÎÒÃÇͨ¹ýä¯ÀÀÆ÷ÇëÇó·þÎñÆ÷ÉϵÄij¸ö×ÊÔ´µÄʱºò£¬¿ÉÄÜÊÇJSP£¬Ò²¿ÉÄÜÊÇServlet£¬Èç¹ûÒª·ÃÎʵÄ×ÊÔ´²»´æÔÚ£¬¾Í»á²úÉú404´íÎó£¬404´íÎó¿ÉÄÜÊÇÓ¦Óñ¾ÉíµÄÎÊÌ⣬ÀýÈçûÓÐÕý³£²¿Êð¡¢Ãû×Öд´íÁË£¬Ò²¿ÉÄÜÊÇÎļþµÄÎÊÌ⣬JSPÎļþ²»´æÔÚ¡¢Ãû×Ö´íÎ󣬻òÕßServleûÓÐÅäÖá£
¸ù¾ÝÕâЩÇé¿ö£¬404´íÎóµÄ½â¾ ......
//ת×Ôhttp://blog.csdn.net/zqhf8/archive/2007/07/09/1683938.aspx
1¡£ÔÀí¼ò½é
dtreeÊÇÒ»¸öÃâ·ÑµÄjavascript½Å±¾£¬Ö»Ð趨ÒåÓÐÏ޵ļ¸¸ö²ÎÊý£¬¾Í¿ÉÒÔ×ö³öƯÁÁµÄÊ÷ÐͲ˵¥¡£ÏÂÔØĿ¼£ºhttp://www.destroydrop.com/javascripts/tree/
ÒÔÏÂÊÇdtreeµÄÓ÷¨Ê¾Àý£º
1£©³õʼ»¯²Ëµ¥
<script t ......
À´Ô´ÓÚ¡¶Java¡¢javaEEÈí¼þ¹¤³Ìʦ¾ÍÒµÇóÖ°Êֲᡷ
1 HttpServletRequestÀàµÄrequest¶ÔÏ󣺴ú±íÇëÇó¶ÔÏó£¬Ö÷ÒªÓÃÓÚ½ÓÊÜ¿Í»§¶Ëͨ¹ýHTTPÐÒéÁ¬½Ó´«Êäµ½·þÎñÆ÷µÄÊý¾Ý¡£
2 HttpServletResponseÀàµÄresponse£º´ú±íÏìÓ¦¶ÔÏó£¬Ö÷ÒªÓÃÓÚÏò¿Í»§¶Ë·¢ËÍÊý¾Ý¡£
3 JspWriterÀàµÄout¶ÔÏó:Ö÷ÒªÓÃÓÚÏò¿Í»§¶ËÊä³öÊý¾Ý£¬OutµÄ»ùÀàÊÇJspWriter¡ ......