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

jsp»ù´¡ÖªÊ¶£¨ÕûÀí£©

¸Õ¿ªÊ¼Ñ§jsp£¬×öµÄÒ»µãÌý¿Î±Ê¼Ç¡£
1.jspÈý´óÖ¸Áî
 <%@ page ~~~~~~~~ %>
 <%@ include file=""%>
 <%@ taglib  url="" prfix=""%>
2.if(username.equals(""))
 out.println("ÐÕÃû²»ÄÜΪ¿Õ£¬Çë<a href=javascript:history.back()>·µ»Ø")£»
&&·ÀÖ¹Ö±½ÓÔÚä¯ÀÀÆ÷ÖÐÊäÈë¼ì²âÒ³Ãæ,²úÉú¿ÕÖ¸Õë´íÎ󣬿ÉÒÔÊäÈë if(username==null|| ursrname.equals(""));
3.ä¯ÀÀÆ÷µÄĬÈϱàÂëÊÇiso8859-1£¬ËùÒÔ¶ÔÓÚÌá½»µÄÖÐÎÄ»á²úÉúÂÒÂë¡£½â¾ö·½°¸£º¶ÔÓÚpost·½·¨Ìá½»µÄÊý¾Ý£¬ÔÚ´¦ÀíÒ³ÃæʹÓÃrequest.setCharacterEncoding("gbk");
¶ÔÓÚpost¡¢get»òurl´«²Î£¬¿ÉʹÓÃString nstr= new String(request.getParameter("nstr").getBytes("iso8850-1"),"gbk");»òÕßÔÚserverÎļþÖнøÐÐÅäÖã¬ÉèÖÃbodyEncodingforurl="true";
4.String[] love=request.getParameterValue("love")//»ñÈ¡¸´Ñ¡¿òÑ¡ÔñµÄ²ÎÊý
´òÓ¡£ºfor(String s:love){ out.println(s +" ");}
5.¿Í»§¶ËÌøת£ºÊÇÖ¸·þÎñÆ÷½«ÇëÇó½á¹û·µ»Ø¸ø¿Í»§¶Ë£¬¿Í»§¶ËÔÙÏò·þÎñÆ÷·¢ÆðÁíÒ»´ÎÇëÇó£¬ÔÚ¿Í»§¶ËÌøת¹ý³ÌÖУ¬¿Í»§¶Ëµ÷תºóµÄurlÊÇ×îºóÒ»´ÎÇëÇóµÄµØÖ·¡£
¿Í»§¶ËÌøת¹»½øÐÐÍøÕ¾ÍâÌøת
¿Í»§¶ËÌøתÓÐÒÔϼ¸ÖÖÐÎʽ£º
 *Á´½Ó<a href=“”>
 *±íµ¥Ìá½»
 *<meta http-equiv="refresh" content="3;url="next.jsp"">
 *javascript:history.back();history.forward();//ʹÓô˷½·¨ Ô­À´ÌîдµÄÐÅÏ¢²»»áÇå³ý
 *response.sendRedirect("next.jsp");
 *response.setHeader("refresh","3;url=next.jsp")
·þÎñÆ÷¶ËÌøת£¨ÈÝÆ÷ÄÚÌøת£©£ºÄܹ»×Ô¶¯µÄÔÚ·þÎñÆ÷ÄÚ²¿½øÐÐÒ³ÃæµÄת»»£¬ËùÒÔ¶ÔÓÚ¿Í»§¶ËÀ´Ëµ£¬ÕâÖÖÌøתÊÇ͸Ã÷µÄ¡£¶ørequest£¬·þÎñÆ÷ÌøתֻÄÜÊÇÕ¾µãÄÚÌøת
·þÎñÆ÷ÌøתµÄÐÎʽ£º
 *<jsp:forward page="">
 *pageContent.forward("")
 *pagecontent.get
 *¿Í»§¶ËÌøתʱµÄ“/”´ú±í·þÎñÆ÷µÄ¸ù
 ·þÎñÆ÷Ìøת£¨ÈÝÆ÷ÄÚÌøת£©£¬Äܹ»×Ô¶¯µÄÔÚ·þÎñÆ÷ÄÚ²¿½øÐÐÌøת
 *·þÎñÆ÷ÌøתʱµÄ"/"´ú±íÕ¾µãµÄ¸ù
6.String path=request.getContextPath();»ñÈ¡Õ¾µãĿ¼Ãû¡£
  ÒÔ"/"¿ªÊ¼µÄ·¾¶´ú±í¾ø¶Ô·¾¶£¬ÆäËû´ú±íÏà¶Ô·¾¶
 Ïà¶Ô·¾¶Óë¾ø¶Ô·¾¶µÄʹÓÃÊÓÇé¿ö¶ø¶¨
7.¾²Ì¬°üº¬£ºÊ¹ÓÃincludeÖ¸Áî°ÑһЩ¹«¹²µÄÄÚÈÝ°üº¬½øÀ´£¬ÈçÐÂÀ˵ĵ¼º½À¸
 *°üº¬µÄÒ³ÃæÖв»ÒªÊ¹Óúͱ


Ïà¹ØÎĵµ£º

ÎÒµÄJSPѧϰ±Ê¼Ç JSPÒ³ÃæÖеÄÖ¸Áî

JSPµÄÖ¸ÁîÊÇÓÃÀ´°üº¬ÍⲿÎļþ»òÊǽøÐÐÒ³ÃæÈ«¾ÖÉèÖõģ»ËüµÄÓÐÈýÖÖ£¬·Ö±ðÊÇpage£¬include£¬taglibÖ¸Áî
1.pageÖ¸Áî
 ÐÎÈç<%@page ÊôÐÔ='Öµ'    ÊôÐÔ='Öµ'   ........ %>
 ÊôÐÔÓУº
 language=''java''   £º É趨jspÒ³ÃæµÄ½Å±¾ÓïÑÔ£¬Ä¿Ç°Ö»Ö§³Öjava£¬Ä¬ÈÏÊÇjava ......

jspÖÐincludeµÄÁ½ÖÖÐÎʽ

jspÖÐincludeµÄÁ½ÖÖÐÎʽ:      1.<%@ include file=” ”%>
                                 &nbs ......

jspÖÐÎÄÂÒÂë½â¾ö·½°¸


1¡¢jspÒ³ÃæÂÒÂ룺
ÔÚjspÒ³Ã濪ʼÌí¼Ó<%pageEncoding="uft-8"%>
2¡¢servletÊä³öÂÒÂ룺
ÔÚÊä³öÄÚÈÝ֮ǰ£¬ÏÈÖ´ÐÐresponse.setContentType
("text/html;charset=utf-8")
3¡¢ÔÚformÀïÓÃpost·½Ê½Ìá½»²ÎÊý£º
1£©½ÓÊÕʱ¼Órequest.setCharacterEncoding("utf-8")
2£©Ê¹ÓùýÂËÆ÷£¬ÔÚ½ÓÊÕ²ÎÊý֮ǰ£¬É趨´«µÝµÄ²ÎÊýÄ ......

ÈçºÎÒ»¸öjspÒ³Ãæ´¦Àí¶à¸öform±íµ¥

Ê×ÏÈÊÇÌá½»Ò³Ã棺Èý¸ö±íµ¥(form1,form2,form3)
         <form name="form1" method="post" action="checklogin.jsp" class="niceform">
            <input name="qx" type="hidden" value="3">
&nb ......

JavaScript ºÍJSP Á¬½ÓSqlServer Êý¾Ý¿â

µÚÒ»ÖÖ JavaScriptÁ¬½ÓÊý¾Ý¿â£º
<mce:script language="JavaScript"><!--
// ´´½¨Êý¾Ý¿â¶ÔÏó
var objdbConn = new ActiveXObject("ADODB.Connection");
// DSN×Ö·û´®
var strdsn = "Driver={SQL Server};SERVER=192.168.0.210;UID=xhb;PWD=xhb;DATABASE=books";
// ´ò¿ªÊý¾ÝÔ´
objdbConn.Open(strdsn);
// ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ