´«ÖDz¥¿ÍJavaÅàѵ JSPÄÚÖöÔÏó¡¢Òì³£´¦ÀíÓëÂÒÂëÎÊÌâ
JSP¾Å´óÄÚÖöÔÏó£º
1.ÓëServletÓйصÄÒþº¬µÄ¶ÔÏó
(1)page page¶ÔÏó¶ÔÓ¦JavaÖеĹؼü×Öthis,Ëü´ú±íµ±Ç°JSPÒ³Ãæ
(2)config Config¶ÔÏóʹÓÃWebÈÝÆ÷ÔÚ³õʼ»¯JSP֮ǰµÃµ½JSPÅäÖÃÐÅÏ¢£¬configµÄ×÷ÓÃÓòΪÕû¸öÒ³Ã棬Ó÷¨¸úservletConfigÏàͬ
2.ÓëInput/OutputÓйصÄÒþº¬¶ÔÏó
(3)out out¶ÔÏó½«ÏìÓ¦µÄÐÅÏ¢Êä³öµ½ÍøÒ³ÉÏ£¬Æ仺³å´óСͨ¹ýpageÖ¸Áî±êÇ©µÄbufferÊôÐÔÉèÖÃ
(4)request ·â×°ÁËä¯ÀÀÆ÷·¢³öµÄÇëÇó¶ÔÏó£¬ËüµÄ×÷ÓÃÓòÊÇÒ»¸öÍêÕûµÄÇëÇó£¬Õ⽫×÷Ϊ_jspServiceµÄÈë¿Ú²ÎÊý
(5)response ·â×°ÏìÓ¦ÄÚÈݵĶÔÏó£¬×÷ÓÃÓòÊÇÕû¸öÒ³Ãæ³£Ó÷½·¨:response.setHeader("refresh","1;url="Ò³ÃæÃû³Æ""); response.sendRedirect("Ò³ÃæÃû³Æ")Öض¨Ïò
3.JSPÖ´ÐÐʱ£¬ÌṩÓйØContextµÄÒþº¬¶ÔÏó
(6)session ¿Í»§¶Ë·¢ËÍÒ»¸öÇëÇóʱ£¬ÔÚ·þÎñÆ÷ÉϽ«´´½¨Ò»¸ö»á»°Î¬»¤Õâ¸ö¿Í»§µÄ¸÷ÖÖ²Ù×÷£¬¸Ã¶ÔÏó³ÆΪsession,Ö»ÒªÖ¸Áî±êÇ©ÖÐûÓн«»á»°È¡Ïû(<%@ page session=”false”%>,¾Í¿ÉÒÔʹÓøöÔÏó£¬Í¨¹ýsession¶ÔÏóµÄsetAttributeºÍgetAttribute·½·¨¿Éά»¤sessionÖеĶÔÏó¡£µ±session=falseʱ£¬¿ÉÒÔÓÃrequest.getSession()·½·¨»ñÈ¡session
(7)application ËüÌṩÁËÒ»×éºÍWebÈÝÆ÷ͨÐŵķ½·¨£¬Ã¿¸öÓ¦ÓóÌÐò¶¼ÓÐÒ»¸öÉÏÏÂÎÄ£¬ÕâÒâζ×ÅApplication¶ÔÏóÄܹ»ÔÚÓ¦ÓóÌÐòµÄÕû¸öÉúÃüÖÜÆÚ·ÃÎÊ¡£ÓëservletµÄservletContext¶ÔÏóÓ÷¨Ïàͬ
(8)pageContext pageContext¶ÔÏó·â×°Á˵±Ç°JSPÒ³ÃæµÄÔËÐÐÐÅÏ¢£¬ËüÌṩÁË·µ»ØJSPÒ³ÃæµÄÆäËûÒþʽ¶ÔÏóµÄ·½·¨¡£ PageContextÀàÖж¨ÒåÁËÒ»¸ösetAttribute·½·¨À´½«¶ÔÏó´æ´¢½øpageContext¶ÔÏóÄÚ²¿µÄÒ»¸öHashMap¶ÔÏóÖУ¬Í¬Ê±Ò²¶¨ÒåÁËÒ»¸ögetAttribute·½·¨À´¼ìË÷´æ´¢ÔÚ¸ÃHashMap¶ÔÏóÖеĶÔÏó¡£PageContextÀà³ýÁË¿ÉÒÔ´æ´¢ºÍ¼ìË÷×ÔÉíÖеÄÊôÐÔ¶ÔÏóÍ⣬»¹¶¨ÒåÁË¿ÉÒÔ´æ´¢ºÍ¼ìË÷ÆäËûÓò·¶Î§ÄÚµÄÊôÐÔ¶ÔÏóµÄ·½·¨¡£
4.ÓëErrorÓйضÔÏóµÄÒþº¬¶ÔÏó
(9)exception ÊÇjava.lang.ThrowableµÄÒ»¸öʵÀý£¬Ëü´ú±íδÆË»ñµÄÒì³££¬Ö»ÓÐÔÚpageÖ¸ÁîÖÐÖ¸¶
Ïà¹ØÎĵµ£º
Ò»¡¢ ¶¨Òå
·ÅÔÚÒ»¸öÀàµÄÄÚ²¿µÄÀàÎÒÃǾͽÐÄÚ²¿Àà¡£
¶þ¡¢ ×÷ÓÃ
1.ÄÚ²¿Àà¿ÉÒԺܺõÄʵÏÖÒþ²Ø
Ò»°ãµÄ·ÇÄÚ²¿À࣬ÊDz»ÔÊÐíÓÐ private ÓëprotectedȨÏ޵ģ¬µ«ÄÚ²¿Àà¿ÉÒÔ
2£®ÄÚ²¿ÀàÓµÓÐÍâΧÀàµÄËùÓÐÔªËصķÃÎÊȨÏÞ
3.¿ÉÊÇʵÏÖ¶àÖؼ̳Ð
4.¿ÉÒÔ±ÜÃâÐ޸ĽӿڶøʵÏÖͬһ¸öÀàÖÐÁ½ÖÖͬÃû·½·¨µÄµ÷Óá£
Èý¡¢ ......
public static void getConnAndTableStruct() {
Connection connection = null;
PreparedStatement pstmt = null;
ResultSetMetaData rsmd = null;
try {
// mysqlÁ¬½Ó
//Class.forName("org.gjt.mm.mysql.Driver");
//connection = DriverManager.g ......
Ç뿼ÂÇÏÂÃæÕâ¶Î»°ËùÃèÊöµÄÎÊÌ⣺
TomÔÚÒ»¼ÒÆû³µÅä¼þÉ̵깺ÂòÁËÒ»¸ö¼ÛÖµ$1.10µÄ»ð»¨Èû£¬µ«ÊÇËûÇ®°üÖж¼ÊÇÁ½ÃÀÔªÒ»Õŵij®Æ±¡£Èç¹ûËûÓÃÒ»ÕÅÁ½ÃÀÔªµÄ³®Æ±Ö§¸¶Õâ¸ö»ð»¨Èû£¬ÄÇôӦ¸ÃÕÒ¸øËû¶àÉÙÁãÇ®ÄØ£¿
ÏÂÃæÊÇÒ»¸öÊÔͼ½â¾öÉÏÊöÎÊÌâµÄ³ÌÐò£¬Ëü»á´òÓ¡³öʲôÄØ£¿
public class Change{
public static void main(String args[ ......
תÐͱ»ÓÃÀ´½«Ò»¸öÊýÖµ´ÓÒ»ÖÖÀàÐÍת»»µ½ÁíÒ»ÖÖÀàÐÍ¡£ÏÂÃæµÄ³ÌÐòÁ¬ÐøʹÓÃÁËÈý¸öתÐÍ¡£ÄÇôËüµ½µ×»á´òÓ¡³öʲôÄØ£¿
public class Multicast{
public static void main (String[] args){
System.out.println((int)(char)(byte) -1);
}
}
ÎÞÂÛÄãÔõÑù·ÖÎöÕâ¸ö³ÌÐò£¬¶¼»á¸Ðµ½ºÜÃÔ»ó¡£ËüÒÔintÊýÖµ-1¿ªÊ¼£¬È»ºó´ÓintתÐÍÎ ......