JavaÃæÊÔÌ⣨4£©
58¡¢Ï̵߳Ļù±¾¸ÅÄî¡¢Ï̵߳Ļù±¾×´Ì¬ÒÔ¼°×´Ì¬Ö®¼äµÄ¹Øϵ
¡¡¡¡Ïß³ÌÖ¸ÔÚ³ÌÐòÖ´Ðйý³ÌÖУ¬Äܹ»Ö´ÐгÌÐò´úÂëµÄÒ»¸öÖ´Ðе¥Î»£¬Ã¿¸ö³ÌÐòÖÁÉÙ¶¼ÓÐÒ»¸öỊ̈߳¬Ò²¾ÍÊdzÌÐò±¾Éí¡£
JavaÖеÄÏß³ÌÓÐËÄÖÖ״̬·Ö±ðÊÇ£ºÔËÐС¢¾ÍÐ÷¡¢¹ÒÆð¡¢½áÊø¡£
59¡¢JSPµÄ³£ÓÃÖ¸Áî
<%@page language="java" csession="true" buffer="64kb" autoFlush="true" isThreadSafe="true"info="text" errorPage="error.jsp" isErrorPage="true" isELIgnored="true"pageEncoding="gb2312" import="java.sql.*"%>
isErrorPage(ÊÇ·ñÄÜʹÓÃException¶ÔÏó)£¬isELIgnored(ÊÇ·ñºöÂÔ±í´ïʽ)
<%@include file="filename"%>
<%@taglib prefix="c"uri="http://......"%>
60¡¢Ê²Ã´Çé¿öϵ÷ÓÃdoGet()ºÍdoPost()£¿
¡¡¡¡JspÒ³ÃæÖеÄform±êÇ©ÀïµÄmethodÊôÐÔΪgetʱµ÷ÓÃdoGet()£¬Îªpostʱµ÷ÓÃdoPost()¡£
61¡¢servletµÄÉúÃüÖÜÆÚ
¡¡¡¡webÈÝÆ÷¼ÓÔØservlet£¬ÉúÃüÖÜÆÚ¿ªÊ¼¡£Í¨¹ýµ÷ÓÃservletµÄinit()·½·¨½øÐÐservletµÄ³õʼ»¯¡£Í¨¹ýµ÷ÓÃservice()·½·¨ÊµÏÖ£¬¸ù¾ÝÇëÇóµÄ²»Í¬µ÷Óò»Í¬µÄdo***()·½·¨¡£½áÊø·þÎñ£¬webÈÝÆ÷µ÷ÓÃservletµÄdestroy()·½·¨¡£
62¡¢ÈçºÎÏÖʵservletµÄµ¥Ïß³Ìģʽ
<%@ page isThreadSafe="false"%>
63¡¢Ò³Ãæ¼ä¶ÔÏ󴫵ݵķ½·¨
request£¬session£¬application£¬cookieµÈ
64¡¢JSPºÍServletÓÐÄÄЩÏàͬµãºÍ²»Í¬µã£¬ËûÃÇÖ®¼äµÄÁªÏµÊÇʲô£¿
¡¡¡¡JSPÊÇServlet¼¼ÊõµÄÀ©Õ¹£¬±¾ÖÊÉÏÊÇServletµÄ¼òÒ×·½Ê½£¬¸üÇ¿µ÷Ó¦ÓõÄÍâ±í±í´ï¡£JSP±àÒëºóÊÇ"Ààservlet"¡£ServletºÍJSP×îÖ÷ÒªµÄ²»Í¬µãÔÚÓÚ£¬ServletµÄÓ¦ÓÃÂß¼ÊÇÔÚJavaÎļþÖУ¬²¢ÇÒÍêÈ«´Ó±íʾ²ãÖеÄHTMLÀï·ÖÀ뿪À´¡£¶øJSPµÄÇé¿öÊÇJavaºÍHTML¿ÉÒÔ×éºÏ³ÉÒ»¸öÀ©Õ¹ÃûΪ.jspµÄÎļþ¡£JSP²àÖØÓÚÊÓͼ£¬ServletÖ÷ÒªÓÃÓÚ¿ØÖÆÂß¼¡£
65¡¢ËÄÖֻỰ¸ú×Ù¼¼Êõ
»á»°×÷ÓÃÓòServletsJSP Ò³ÃæÃèÊö
pageÊÇ´ú±íÓëÒ»¸öÒ³ÃæÏà¹ØµÄ¶ÔÏóºÍÊôÐÔ¡£Ò»¸öÒ³ÃæÓÉÒ»¸ö±àÒëºÃµÄ Java servlet Àࣨ¿ÉÒÔ´øÓÐÈÎºÎµÄ include Ö¸Áµ«ÊÇûÓÐ include ¶¯×÷£©±íʾ¡£Õâ¼È°üÀ¨ servlet ÓÖ°üÀ¨±»±àÒë³É servlet µÄ JSP Ò³Ãæ
requestÊÇÊÇ´ú±íÓë Web ¿Í»§»ú·¢³öµÄÒ»¸öÇëÇóÏà¹ØµÄ¶ÔÏóºÍÊôÐÔ¡£Ò»¸öÇëÇó¿ÉÄÜ¿çÔ½¶à¸öÒ³Ã棬Éæ¼°¶à¸ö Web ×é¼þ£¨ÓÉÓÚ forward Ö¸ÁîºÍ include ¶¯×÷µÄ¹Øϵ£©
sessionÊÇÊÇ´ú±íÓëÓÃÓÚij¸ö Web ¿Í»§»úµÄÒ»¸öÓû§ÌåÑéÏà¹ØµÄ¶ÔÏóºÍÊôÐÔ¡£Ò»¸ö Web »á»°¿ÉÒÔÒ²¾³£»á¿çÔ½¶à¸ö¿Í»§»úÇëÇó
applicationÊÇÊÇ´ú±íÓëÕû¸ö Web Ó¦ÓóÌÐòÏà¹ØµÄ¶ÔÏóºÍÊôÐÔ¡£
Ïà¹ØÎĵµ£º
ʮһ javaÃæÏò¶ÔÏó³ÌÐòÉè¼Æ(µ¥Ì¬Éè¼Æģʽ)
/**
* ÃæÏò¶ÔÏóÖ®Áù
* µ¥Ì¬Ä£Ê½Éè¼Æ
* ËùνÀàµÄµ¥Ì¬Éè¼Æģʽ£¬¾ÍÊDzÉÈ¡Ò»¶¨µÄ·½·¨±£Ö¤ÔÚÕû¸öµÄÈí¼þϵͳÖУ¬¶Ôij¸öÀàÖ»ÄÜ´æÔÚÒ»¸ö¶ÔÏóʵÀý£¬
* ²¢ÇÒ¸ÃÀàÖ»Ìṩһ¸öÈ¡µÃÆä¶ÔÏóʵÀýµÄ·½·¨¡£
*/
class Single
{
private static int coun ......
Ôü×Ò»ØÊÕµÄã£ÂÛ
Ëùν“³ÉÒ²ÏôºÎ°ÜÏôºÎ”¡£JavaµÄÔü×Ò»ØÊÕȷȷʵʵ´øµ½Á˺ܶàºÃ´¦£¬Îª¿ª·¢´ø»ØÁË·½±ã¡£µ«ÊÇÔÚһЩ¸ßÐÔÄÜ¡¢¸ß²¢·¢µÄÇé¿öÏ£¬Ôü×Ò»ØÊÕÈ·±äΪÁËǯÖÆJavaʹÓõÄÆ¿¾±¡£µ±Ç°JDKµÄÔü×Ò»ØÊÕËã·¨£¬Ê¼ÖÕû·¨½â¾öÔü×Ò»ØÊÕʱµÄÔÝÍ£ÎÊÌ⣬ÓÉÓÚÕâ¸öÔÝÍ£ÑÏÖØÓ°ÏìÁ˳ÌÐòµÄºôӦʱ¼ä£¬´Ù³É¶ÂÈû»ò»ý¾Û¡£ÕâÒ²ÊǺóÐøJDK ......
ÔËÐÐʱ°ó¶¨Ò²½Ð¶¯Ì¬°ó¶¨£¬ËüÊÇÒ»ÖÖµ÷ÓöÔÏó·½·¨µÄ»úÖÆ¡£Javaµ÷ÓöÔÏó·½·¨Ê±£¬Ò»°ã²ÉÓÃÔËÐÐʱ°ó¶¨»úÖÆ¡£
1£®JavaµÄ·½·¨µ÷Óùý³Ì
±àÒëÆ÷²é¿´¶ÔÏóµÄÉùÃ÷ÀàÐͺͷ½·¨Ãû£¨¶ÔÏó±äÁ¿µÄÉùÃ÷ÀàÐÍ£©¡£Í¨¹ýÉùÃ÷ÀàÐÍÕÒµ½·½·¨ÁÐ±í¡£
±àÒëÆ÷²é¿´µ÷Ó÷½·¨Ê±ÌṩµÄ²ÎÊýÀàÐÍ¡£
Èç¹û·½·¨ÊÇprivate¡¢static¡¢final»òÕß¹¹ÔìÆ÷£¬±àÒëÆ ......
40¡¢¹¹ÔìÆ÷ConstructorÊÇ·ñ¿É±»override?
¡¡¹¹ÔìÆ÷Constructor²»Äܱ»¼Ì³Ð£¬Òò´Ë²»ÄÜÖØдOverriding£¬µ«¿ÉÒÔ±»ÖØÔØOverloading¡£
41¡¢ÊÇ·ñ¿ÉÒԼ̳ÐStringÀà?
¡¡¡¡StringÀàÊÇfinalÀà¹Ê²»¿ÉÒԼ̳С£
42¡¢swtichÊÇ·ñÄÜ×÷ÓÃÔÚbyteÉÏ£¬ÊÇ·ñÄÜ×÷ÓÃÔÚlongÉÏ£¬ÊÇ·ñÄÜ×÷ÓÃÔÚStringÉÏ?
¡¡¡¡switch£¨expr1£©ÖУ¬expr1ÊÇÒ»¸öÕûÊý±í´ ......