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 ·½·¨ÔÚ·þÎñÆ÷¶ËÄÚ²¿½«ÇëÇóת·¢¸øÁíÍâÒ»¸ö×ÊÔ´£¬ä¯ÀÀÆ÷Ö»ÖªµÀ·¢³öÁËÇëÇ󲢵õ½ÁËÏìÓ¦½á¹û£¬²¢²»ÖªµÀÔÚ·þÎñÆ÷³ÌÐòÄÚ²¿·¢ÉúÁËת·¢ÐÐΪ¡£Õâ¸ö¹ý³ÌºÃ±È´ÂºÅ½Ð“ä¯ÀÀÆ÷”µÄÈËдÐÅÕÒÕÅÈý½èÇ®£¬ÕÅÈýûÓÐÇ®£¬ÓÚÊÇÕÅÈýÕÒÀîËĽèÁËһЩǮ£¬ÉõÖÁ»¹¿ÉÒÔ¼ÓÉÏ×Ô¼ºµÄһЩǮ£¬È»ºóÔÙ½«ÕâЩǮ»ã¸øÁË“ä¯ÀÀÆ÷”¡£¿É¼û£¬“ä¯ÀÀÆ÷”Ö»·¢³öÁËÒ»·âÐźÍÊÕµ½ÁËÒ»´Î»Ø¸´£¬ËûÖ»ÖªµÀ´ÓÕÅÈýÄÇÀï½èµ½ÁË
Ïà¹ØÎĵµ£º
Ê×ÏÈ,˵һÏÂ301Öض¨ÏòµÄÒâÒåÓë×÷ÓÃ(ÍøÉÏÕÒµÄÏà¹Ø×ÊÁÏ)
ÆäʵÕâ¾ÍÉæ¼°µ½ÁËSEOµÄ֪ʶ¡£
ʲôÊÇ301תÏò£¿
´ÓËÑË÷ÒýÇæÓÅ»¯½Ç¶È³ö·¢£¬301Öض¨ÏòÊÇÍøÖ·Öض¨Ïò×îΪ¿ÉÐеÄÒ»ÖÖ°ì·¨¡£µ±ÍøÕ¾µÄÓòÃû·¢Éú±ä¸üºó£¬ËÑË÷ÒýÇæÖ»¶ÔÐÂÍøÖ·½øÐÐË÷Òý£¬Í¬Ê±ÓÖ»á°Ñ¾ÉµØÖ·ÏÂÔÓеÄÍⲿÁ´½ÓÈçÊýתÒƵ½ÐµØÖ·Ï£¬´Ó¶ø²»»áÈÃÍøÕ¾µÄÅÅÃûÒòΪÍøÖ ......
ÔÚJspÖе÷ÓÃSerlvetÖÐÒѾ´æ´¢ÁËÐÅÏ¢µÄ JavaBean.
ServletÖÐÒѾ°ÑÊý¾Ý¿âµÄÐÅÏ¢±£´æµ½JavaBeanÖÐ,ÔÙ°ÑJavaBean±£´æµ½SessionÖÐ.
Jsp¿ªÊ¼µ÷ÓÃ:
<jsp:useBean id="key" type="ClassName" scope="Session" />
<jsp:getProperty name="key" property="PropertyName" />
ÎÞ·¨¶Á³öÐÅÏ¢:
ÔÒò: JavaBean ÖÐÊôÐÔµ ......
JspÊÇÒ»¸öºÜÈÈÃŵĻ°Ì⣬µ«Èôó¶àÊýÈ˶¼Í·Í´µÄÊÇJSPÒ³ÃæÖеÄÂÒÂëÎÊÌ⣬±ÊÕßÉíÓÐÌå»á£»ÔøΪÁ˽â¾öÖÐÎÄÂÒÂëÎÊÌâÓôÃÆÁ˺ü¸Ì죬ÊÔÁ˺ܶ෽·¨¶¼²»ÐС£×îºóÔÚJSPרҵÈËÊ¿µÄ°ïÖúÏ£¬ÖÕÓÚ½â¾ö¡£Ö®ºó±ÊÕßÔø¶Ô´Ë×öÁËһЩСµÄÑо¿¡£
Ê×ÏÈÎÒÃÇÏÈÁ˽âÒ»ÏÂÎÊÌâµÄÔÒò¡£Ò»°ãÇé¿öÔÚÔÚÿ¸öJSPÒ³µÄÍ·²¿¶¼ÓÐÕâÑùÒ» ......
Ò»¡¢´¦ÀíajaxÇëÇóµÄjspÎļþ£ºauto.jsp
<%@ page contentType="text/html; charset=gb2312" %>
<%
//ÉèÖÃÊä³öÐÅÏ¢µÄ¸ñʽ¼°×Ö·û¼¯
response.setContentType("text/xml; charset=UTF-8");
response.setHeader("Cache-Control","no-cache&q ......
1 javascript £¬ÉèÖÃÒ»¸ö±äÁ¿£¬Ö»ÔÊÐíÌá½»Ò»´Î¡£
2 »¹ÊÇjavascript£¬½«Ìá½»°´Å¥»òÕßimageÖÃΪdisable
onsubmit="getElById('submitInput').disabled = true; return true;">
3 ÀûÓÃstrutsµÄͬ²½ÁîÅÆ»úÖÆ
......