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

JSPÄÚÖöÔÏóÖ®request

HTTP ͨÐÅЭÒéÊǿͻ§Óë·þÎñÆ÷Ö®¼äÒ»ÖÖÌá½»£¨ÇëÇó£© ÐÅÏ¢ÓëÏìÓ¦ÐÅÏ¢
£¨request/respone£©µÄͨÐÅЭÒé¡£ÔÚJSP ÖУ¬ÄÚÖöÔÏórequest ·â×°ÁËÓû§Ìá½»µÄÐÅÏ¢£¬
ÄÇô¸Ã¶ÔÏóµ÷ÓÃÏàÓ¦µÄ·½·¨¿ÉÒÔ»ñÈ¡·â×°µÄÐÅÏ¢£¬¼´Ê¹ÓøöÔÏó¿ÉÒÔ»ñÈ¡Óû§Ìá½»µÄÐÅ
Ï¢¡£
¿Í»§Í¨³£Ê¹ÓÃHTML ±íµ¥Ïò·þÎñÆ÷µÄij¸öJSP Ò³ÃæÌá½»ÐÅÏ¢£¬±íµ¥µÄÒ»°ã¸ñʽÊÇ£º
<FORM method= get | post action= “Ìá½»ÐÅÏ¢µÄÄ¿µÄµØÒ³Ãæ”>
Ìá½»ÊÖ¶Î
</FORM>…..
ÆäÖÐ<Form>ÊÇ±íµ¥±êÇ©£¬method ȡֵget »òpost¡£Get ·½·¨ºÍpost ·½·¨µÄÖ÷񻂿±ð
ÊÇ£ºÊ¹ÓÃget ·½·¨Ìá½»µÄÐÅÏ¢»áÔÚÌá½»µÄ¹ý³ÌÖÐÏÔʾÔÚä¯ÀÀÆ÷µÄµØÖ·À¸ÖУ¬¶øpost ·½·¨
Ìá½»µÄÐÅÏ¢²»»áÏÔʾÔÚµØÖ·À¸ÖС£Ìá½»ÊֶΰüÀ¨£ºÍ¨¹ýÎı¾¿ò¡¢ÁÐ±í¡¢Îı¾ÇøµÈ£¬ÀýÈ磺
<FORM action="tom.jsp" method= “post” >
<INPUT type="text" name="boy" value= “ok” >
<INPUT TYPE="submit" value=" Ëͳö" name= “submit”>
</FORM>
¸Ã±íµ¥Ê¹ÓÃpost·½·¨ÏòÒ³Ãætom.jsp Ìá½»ÐÅÏ¢£¬Ìá½»ÐÅÏ¢µÄÊÖ¶ÎÊÇ£ºÔÚÎı¾¿òÊäÈëÐÅ
Ï¢£¬ÆäÖÐĬÈÏÐÅÏ¢ÊÇ“ok”£»È»ºóµã»÷“Ëͳö”°´Å¥Ïò·þÎñÆ÷µÄJSP Ò³Ãætom.jsp Ìá½»ÐÅ
Ï¢¡£
request ¶ÔÏó¿ÉÒÔʹÓÃgetParameter(String s) ·½·¨»ñÈ¡¸Ã±íµ¥Í¨¹ýtext Ìá½»µÄÐÅÏ¢£¬
±ÈÈ磺
request.getParameter(“boy”);
Ò»¡¢»ñÈ¡¿Í»§Ìá½»µÄÐÅÏ¢
request ¶ÔÏó»ñÈ¡¿Í»§Ìá½»ÐÅÏ¢µÄ×î³£Óõķ½·¨ÊÇgetParameter(String s) ¡£
ÔÚÏÂÃæµÄÀý×Ó2ÖУ¬Example3_2.jsp ͨ¹ý±íµ¥Ïò×Ô¼ºÌá½»Ò»¸öÕýÊý£¬È»ºó¼ÆËãÕâ¸öÊýµÄƽ·½¸ù
Example3_2.jsp£º
<%@ page contentType="text/html;charset=GB2312" %>
<HTML>
<BODY bgcolor=cyan><FONT size=1>
<FORM action="Example3_2.jsp" method=post name=form>
<INPUT type="text" name="girl">
<INPUT TYPE="submit" value="Enter" name="submit">
</FORM>
<%String textContent=request.getParameter("girl");
double number=0,r=0;
if(textContent==null)
{textContent="";
}
try{ number=Double.parseDouble(textContent);
if(number>=0)
{r=Math.sqrt(number) ;
out.print("<BR>"+String.valueOf(number)+" µÄƽ·½¸ù£º");
out.print("<BR>"+String.valueOf(r));
}
else
{out.print("<


Ïà¹ØÎĵµ£º

jspÖеÄ×Ô¶¨Òå±êÇ©µÄÓ÷¨


±àд×Ô¶¨Òå±êÇ©²½Öè
 
 ±àд±êÇ©´¦ÀíÆ÷£¨´¦Àí±êÇ©µÄJavaÀࣩ£¬ÕâЩÀàÐèҪʵÏÖһЩ¹æ·¶»¯µÄ±êÇ©½Ó¿Ú
 ±àд±êÇ©¿âÃèÊöÎļþ£¨TLD£©£¬Õâ¸öÎļþÃèÊöÁËÿ¸ö±êÇ©ºÍ¶ÔÓ¦µÄJava±êÇ©´¦ÀíÆ÷ÀàÖ®¼äµÄÓ³Éä¹ØÏµ
 ÔÚweb.xmlÖÐÅäÖñêÇ©¿âÎļþµÄURI
 ÔÚJSPÒ³ÃæÖÐÀûÓÃtaglibÖ¸Á±êÇ©¿âÒýÈëµ½Ò³ÃæÖÐ
  ......

¹ØÓÚ¸´Ñ¡¿òµÄÑéÖ¤Óëjspȡֵ(×ªÔØ)

±íµ¥ÈçÏ£º
<form name="form1" action="test.jsp" method="post" onsubmit="return checkData();">
   <input name="checkall1" type="checkbox" value="0" onClick="checkAllBox(this);"/>ȫѡ<br>
   <input name="answer" type="checkbox" value="a"/>A<b ......

JSP iterator


JSPÖнá¹û¼¯ÏÔʾÈçÏ£º
    
<
ww:iterator
 
value
=
"resultList"
 
status
=
"status"
>
    
<
tr
 
class
=
"<ww:if test="
#status.even"
>
row-even
</
ww:if
> ......

´«ÖDz¥¿ÍJavaÅàѵ JSPÄÚÖöÔÏó¡¢Òì³£´¦ÀíÓëÂÒÂëÎÊÌâ

JSP¾Å´óÄÚÖöÔÏó£º
       1.ÓëServletÓйصÄÒþº¬µÄ¶ÔÏó
          (1)page  page¶ÔÏó¶ÔÓ¦JavaÖеĹؼü×Öthis,Ëü´ú±íµ±Ç°JSPÒ³Ãæ
          (2)config  Config¶ÔÏóʹÓÃWebÈÝÆ ......

jsp useBean scopeÊôÐÔµÄÇø·Ö

      scopeÊôÐÔÓÃÓÚÖ¸¶¨JavaBeanʵÀý¶ÔÏóËù´æ´¢µÄÓò·¶Î§£¬ÆäȡֵֻÄÜÊÇpage¡¢request¡¢sessionºÍapplicationËĸöÖµÖеÄÒ»¸ö£¬ÆäĬÈÏÖµÊÇpage¡£
      ÎÒ¿ÉÒÔ²âÊÔÏÂÃæ´úÂ룺
date.jsp
---------------------------------------------------------
<jsp:useBean i ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ