Á˽âJSPÖÐrequestÊôÐÔµÄÓ÷¨
±¾ÎĽéÉÜJSPÖÐrequestÊôÐÔµÄÓ÷¨£¬ÒÔ¼°request.getParameter() ºÍrequest.getAttribute() Çø±ð¡£
Ò»¡¢request.getParameter() ºÍrequest.getAttribute() Çø±ð
1.request.getParameter()È¡µÃÊÇͨ¹ýÈÝÆ÷µÄʵÏÖÀ´È¡µÃͨ¹ýÀàËÆpost£¬getµÈ·½Ê½´«ÈëµÄÊý¾Ý£¬request.setAttribute()ºÍgetAttribute()Ö»ÊÇÔÚwebÈÝÆ÷ÄÚ²¿Á÷ת£¬½ö½öÊÇÇëÇó´¦Àí½×¶Î¡£
2.request.getParameter()·½·¨´«µÝµÄÊý¾Ý£¬»á´ÓWeb¿Í»§¶Ë´«µ½Web·þÎñÆ÷¶Ë£¬´ú±íHTTPÇëÇóÊý¾Ý¡£request.getParameter()·½·¨·µ»ØStringÀàÐ͵ÄÊý¾Ý¡£
request.setAttribute()ºÍgetAttribute()·½·¨´«µÝµÄÊý¾ÝÖ»»á´æÔÚÓÚWebÈÝÆ÷ÄÚ²¿»¹ÓÐÒ»µã¾ÍÊÇ£¬HttpServletRequestÀàÓÐsetAttribute()·½·¨£¬¶øûÓÐsetParameter()·½·¨¡£ÄÃÒ»¸öÀý×ÓÀ´ËµÒ»Ï°ɣ¬¼ÙÈçÁ½¸öWEBÒ³Ãæ¼äΪÁ´½Ó¹Øϵʱ£¬¾ÍÊÇ˵Ҫ´Ó1.JSPÁ´½Óµ½2.JSPʱ£¬±»Á´½ÓµÄÊÇ2.JSP¿ÉÒÔͨ¹ýgetParameter()·½·¨À´»ñµÃÇëÇó²ÎÊý.
¼ÙÈç1.JSPÀïÓÐ
<form name="form1" method="post" action="2.jsp"> ÇëÊäÈëÓû§ÐÕÃû£º<input type="text" name="username"> <input type="submit" name="Submit" value="Ìá½»"> form>
µÄ»°ÔÚ2.JSPÖÐͨ¹ýrequest.getParameter("username")·½·¨À´»ñµÃÇëÇó²ÎÊýusername:
< % String username=request.getParameter("username"); %>µ«ÊÇÈç¹ûÁ½¸öWEB¼äΪת·¢¹Øϵʱ£¬×ª·¢Ä¿µÄWEB¿ÉÒÔÓÃgetAttribute()·½·¨À´ºÍת·¢Ô´WEB¹²Ïírequest·¶Î§ÄÚµÄÊý¾Ý£¬Ò²»¹ÊÇ˵һ¸öÀý×Ó°É¡£ÓÐ1.JSPºÍ2.JSP
1.JSPÏ£ÍûÏò2.JSP´«µÝµ±Ç°µÄÓû§Ãû×Ö£¬ÈçºÎ´«µÝÕâÒ»Êý¾ÝÄØ£¿ÏÈÔÚ1.JSPÖе÷ÓÃÈçÏÂsetAttribute()·½·¨£º
<% String username=request.getParameter("username"); request.setAttribute("username"£¬username); %> <jsp:forward page="2.jsp" /> ÔÚ2.jspÖÐͨ¹ýgetAttribute()·½·¨»ñµÃÓû§Ãû×Ö: <% String username=(String)request.getAttribute("username"); %>
¶þ¡¢request.getAttribute()Óërequest.setAttribute()
request.getAttribute("nameOfObj")¿ÉµÃµ½JSPÒ³ÃæÒ»±íµ¥ÖпؼþµÄValue¡£Æäʵ±íµ¥¿Ø¼þÖеÄObjectµÄ nameÓëvalueÊÇ´æ·ÅÔÚÒ»¸ö¹þÏ£±íÖеģ¬ËùÒÔÔÚÕâÀï¸ø³öObjectµÄname»áµ½¹þÏ£±íÖÐÕÒ³ö¶ÔÓ¦ËüµÄvalue¡£
¶ø²»Í¬Ò³Ãæ¼ä´«ÖµÊ¹ÓÃrequest.setAttribute(positi
Ïà¹ØÎĵµ£º
JSP +Tomcat
Êý¾Ý¿â·ÃÎÊ
×÷ÕߣºÁõÖ¾Ô¶
ÔÚÒ»°ãµÄ
Web
ÏîÄ¿¿ª·¢ÖУ¬¶ÔÊý¾Ý¿âµÄ·ÃÎÊÊDZز»¿ÉÉٵģ¬±¾ÎÄÖ÷Òª½éÉÜÁ½ÖÖÔÚ
ʹÓÃ
Tomcat
×÷Ϊ
Web
·þÎñµÄ
JSP
¿ª·¢ÖзÃÎÊÊý¾Ý¿âµÄ·½·¨£¬Ï£ÍûÄܶԸսӴ¥
JSP
¿ª·¢µÄÅóÓÑÓÐËù°ïÖú¡£
ÓÃ
¹ý
.NET
ƽ̨µÄÅóÓÑÓ¦¸ÃÖªµÀ£¬ÏîÄ¿ÖÐÐèÒª·ÃÎÊÊý¾Ý¿âʱ£ ......
´Ó×òÌ쿪ʼ¾ÍÒ»Ö±ÔÚÍøÉϲéÕÒÊý¾Ý¿âΪSQL server 2000 µÄJSP¿ª·¢»·¾³µÄ´î½¨£¬µ½ÏÖÔÚΪֹÖÕÓÚÄܹ»Õý³£Áª½Ó²¢·ÃÎÊ¡£ÒÔÏÂÊǴµÄ²½Ö裺
1¡¢´ÓÍøÉÏÏÂÔØÒ»¸öSQL server 2000 ¸öÈË°æµÄ°²×°°ü£¬°´ÕÕÌáʾ²Ù×÷£¬µ±ÔÚÉí·ÖÑé֤ʱ£¬Ñ¡Ôñ»ìºÏģʽ£¬Óû§saµÄÃÜÂë¿ÉÒÔΪ¿Õ£¬Ò²¿ÉÒÔ²»Îª¿Õ¡£
2¡¢´ÓÍøÉÏÏÂÔØÒ»¸öSQ ......
ËäÈ»×öÁË´ó°ëÄêµÄweb¿ª·¢ÁË£¬µ«Ò»Ö±¸¡ÓÚ±íÃ棬¶«Î÷»á×ö£¬µ«ºÜ¶àÔÀí²»Í¨£¬ÒªÏë³ÉΪ¼¼ÊõÅ£È˹â»á×öÊÇÔ¶Ô¶²»Ðеģ¬ÒòΪ¼´Ê¹»á×öµ«²»»á½²ÇÒ²»ÄܾÙÒ»·´Èý£¬°¥£¬Ïëµ±Äê¸ßÖÐÊýѧ֮ËùÒÔÕâôºÃ¾ÍÊÇÒòΪ¸ßÖÐÊýѧÔÀíÎÒ¶¼Ò»Çå¶þ³þ£¬¾ÙÒ»·´Èý£¬ÐËÊÖÄíÀ´£¬·´¶øµ½ÁËÏÖÔÚÓе㼱¹¦½üÀû£¬¼±ÓÚÇó³É£¬ÎÒÕâ²»Êǵ¹ÍËÁË ......
дCookie£º
//´Óä¯ÀÀÆ÷È¡µÃÓû§Ãû
String username = request.getParameter("username");
//´Óä¯ÀÀÆ÷È¡µÃÃÜÂë
String password = request.getParameter(" ......