JSPÖеÄÏà¶Ô·¾¶ºÍ¾ø¶Ô·¾¶
1.Ê×ÏÈÃ÷È·Á½¸ö¸ÅÄ
·þÎñÆ÷·¾¶£ºÐÎÈ磺http://192.168.0.1/µÄ·¾¶
WebÓ¦Ó÷¾¶£ºÐÎÈ磺http://192.168.0.1/yourwebappµÄ·¾¶
2.¹ØÓÚÏà¶Ô·¾¶Óë¾ø¶Ô·¾¶µÄÃèÊö£º
ServletÖУ¬"/"´ú±íWebÓ¦ÓõĸúĿ¼¡£ºÍÎïÀí·¾¶µÄÏà¶Ô±íʾ¡£ÀýÈ磺"./" ´ú±íµ±Ç°Ä¿Â¼, "../"´ú±íÉϼ¶Ä¿Â¼¡£ÕâÖÖÀàËƵıíʾ£¬Ò²ÊÇÊôÓÚÏà¶Ô·¾¶¡£ÕâÓëlinuxÖз¾¶µÄ±íÊö·½·¨Ò»Ö£¡
3.¹ØÓÚJSP/ServletÖеÄÏà¶Ô·¾¶ºÍ¾ø¶Ô·¾¶¡£
3.1·þÎñÆ÷¶ËµÄµØÖ·
·þÎñÆ÷¶ËµÄÏà¶ÔµØÖ·Ö¸µÄÊÇÏà¶ÔÓÚÄãµÄwebÓ¦ÓõĵØÖ·£¬Õâ¸öµØÖ·ÊÇÔÚ·þÎñÆ÷¶Ë½âÎöµÄ£¨²»Í¬ÓÚhtmlºÍjavascriptÖеÄÏà¶ÔµØÖ·£¬ËûÃÇÊÇÓÉ¿Í»§¶Ëä¯ÀÀÆ÷½âÎöµÄ£©Ò²¾ÍÊÇ˵ÕâʱºòÔÚjspºÍservletÖеÄÏà¶ÔµØÖ·Ó¦¸ÃÊÇÏà¶ÔÓÚÄãµÄwebÓ¦Ó㬼´Ïà¶ÔÓÚhttp: //192.168.0.1/webapp/µÄ¡£
ÆäÓõ½µÄµØ·½ÓУº
forward£ºservletÖеÄrequest.getRequestDispatcher(address);Õâ¸öaddressÊÇÔÚ·þÎñÆ÷¶Ë½âÎöµÄ£¬ËùÒÔ£¬ÄãÒªforwardµ½a.jspÓ¦¸ÃÕâôд£ºrequest.getRequestDispatcher(“/user/a.jsp”)Õâ¸ö/ Ïà¶ÔÓÚµ±Ç°µÄwebÓ¦ÓÃwebapp£¬Æä¾ø¶ÔµØÖ·¾ÍÊÇ£ºhttp://192.168.0.1/webapp/user/a.jsp¡£ sendRedirect£ºÔÚjspÖÐ<%response.sendRedirect("/rtccp/user/a.jsp");%>
3.2 ¿Í»§¶ËµÄµØÖ·
ËùÓеÄhtmlÒ³ÃæÖеÄÏà¶ÔµØÖ·¶¼ÊÇÏà¶ÔÓÚ·þÎñÆ÷¸ùĿ¼(http://192.168.0.1/)µÄ£¬¶ø²»ÊÇ(¸úĿ¼ÏµĸÃWebÓ¦ÓõÄĿ¼) http://192.168.0.1/webapp/µÄ¡£ HtmlÖеÄform±íµ¥µÄactionÊôÐԵĵØÖ·Ó¦¸ÃÊÇÏà¶ÔÓÚ·þÎñÆ÷¸ùĿ¼(http://192.168.0.1/)µÄ£¬ËùÒÔ£¬Èç¹ûÌá½»µ½a.jsp Ϊ£ºaction£½"/webapp/user/a.jsp"»òaction="<%=request.getContextPath()% >"/user/a.jsp£»
Ìá½»µ½servletΪactiom£½"/webapp/handleservlet" JavascriptÒ²ÊÇÔÚ¿Í»§¶Ë½âÎöµÄ£¬ËùÒÔÆäÏà¶Ô·¾¶ºÍform±íµ¥Ò»Ñù¡£
Òò´Ë£¬Ò»°ãÇé¿öÏ£¬ÔÚJSP/HTMLÒ³ÃæµÈÒýÓõÄCSS,Javascript.ActionµÈÊôÐÔÇ°Ãæ×îºÃ¶¼¼ÓÉÏ
<%=request.getContextPath()%>,ÒÔÈ·±£ËùÒýÓõÄÎļþ¶¼ÊôÓÚWebÓ¦ÓÃÖеÄĿ¼¡£ÁíÍ⣬Ӧ¸Ã¾¡Á¿±ÜÃâʹÓÃÀàËÆ".","./","../../"µÈÀàËƵÄÏà¶Ô¸ÃÎļþλÖõÄÏà¶Ô·¾¶£¬ÕâÑùµ±ÎļþÒƶ¯Ê±£¬ºÜÈÝÒ׳öÎÊÌâ¡£
¼òµ¥µØ˵:
ËùÓеÄ·¾¶£¬¶¼ÊÇÏò·þÎñÆ÷ÇëÇó×ÊÔ´¡£²»Í¬Ö®ÍâÔÚÓÚ£¬Õâ¸ö·¾¶ÊÇÔÚ·þÎñÆ÷¶Ë»¹¿Í»§¶Ë½âÎö£¡
Èç¹ûÄãҪдϵÄÕâ¸ö·¾¶ÊÇÒªÔÚ·þÎñÆ÷¶Ë½âÎöµÄ»°£¬ÄÇôÕâ¸ö·¾¶µÄRootÓ¦¸ÃÊÇÏñhttp: //192.168.0.1/webapp/ÕâÖÖÐÎʽµÄ£¬¼´ÒÔwebappµÄ·¾¶Îª¸ù·¾¶¡£±ÈÈçÔÚOOB
Ïà¹ØÎĵµ£º
»·¾³ÅäÖúú󣬿ª·¢JSP³ÌÐò¾Í·Ç³£¼òµ¥ÁË¡£
File-->New-->Web Project
Ôڸô°¿ÚÖÐÊäÈëһЩ¹¤³Ì»ù±¾ÐÅÏ¢£¬±ÈÈ繤³ÌÃû£¬ÕâÀïÊäÈëΪ test1-01
ÕâÑùÒ»¸ö»ùÓÚJSPµÄÏîÄ¿¾Í½¨Á¢ÆðÀ´ÁË¡£
Package Explorer µÄÏÔʾ·½·¨£º
Windows-->Show View-->Package Explorer ÕâÑù¾ÍÄÜÏÔʾ³öÀ´À²£¡
Ï ......
JSP»·¾³´î½¨µÚÒ»²½¡¢°²×°JDK
1£©¡¢´Ó¹ÙÍøÏÂÔØ°²×°³ÌÐò£ºhttp://java.sun.com/javase/downloads/index.jspÖ»ÒªÏÂÔØÆäÖÐÖ®Ò»°²×°¾Í¿ÉÒÔÁË
2£©¡¢°²×°JDK°ü
[root@linuxas src]cd /usr/local/src [root@linuxas src]# chmod u+x jdk-6u14-linux-i586.bin [root@linuxas&nbs ......
public static List getPageUser(int currentPage) throws Exception {//?List
Connection conn = null;
PreparedStatement prep = null;
ResultSet rs = null ......
Tomcat½«jsp±àÒë³ÉservletºóµÄÎļþ´æ·ÅÔÚ\work\CatalinaĿ¼Ï£¬ÀýÈçjspÎļþ\webapps\hh\h.jsp£¬±àÒëºó
\work\Catalina\localhost\hh\org\apache\jsp\h_jsp.java
servletÎļþºÍ.classÎļþ¶¼ÔÚͬһĿ¼Ï¡£
¿ØÖÆ̨±¨µÄÒì³£ÐÐÊýÊÇÖ¸±àÒë¹ýºóµÄservletÎļþ,¶ø²»ÊÇÄãÔÀ´µÄjspÎļþ£¡ ......
Ê×ÏÈҪ˵µÄ¾ÍÊÇ ajax ÊÇÎÞ·¨ÊµÏÖÉÏ´«ÎļþµÄ£¬¿ÉÒÔÏëÒ»ÏÂajaxÓëºǫ́ͨÐŶ¼ÊÇͨ¹ý´«µÝ×Ö·û´®£¬ÔõôÄÜ´«µÝÎļþÄØ£¿Æäʵ³öÓÚ°²È«¿¼ÂÇjsÊDz»ÄܲÙ×÷ÎļþµÄ£¬ËùÒԾͲ»ÒªÔÙ˵ÓÃajaxÀ´ÊµÏÖÎļþµÄÉÏ´«ÁË£¬ÕâÊDz»¿ÉÄܵġ£
¶ø±¾ÎÄʵÏÖµÄÎļþÉÏ´«Ò²ÊÇÎÞÒ³Ãæˢеģ¬¿ÉÒÔ˵ÊÇÒ»ÖÖ"ÀàËÆAJAX"·½·¨¡£
&n ......