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

jspÎļþ¿ªÍ·path, basePath×÷ÓÃ

ÔÚJSPÖеÄÈç¹ûʹÓà "Ïà¶Ô·¾¶"  ÔòÓпÉÄÜ»á³öÏÖÎÊÌâ. 
ÒòΪ ÍøÒ³ÖÐµÄ "Ïà¶Ô·¾¶" , ËûÊÇÏà¶ÔÓÚ "URLÇëÇóµÄµØÖ·" ȥѰÕÒ×ÊÔ´. 
ÉÏÃæÕâ¾ä»°ÊÇʲôÒâ˼ÄØ ? 
¾Ù¸öÀý×Ó: 
¼ÙÈçÎÒÃÇÓÐÒ»¸öÏîÄ¿: MyApp 
ÔÚ¸ÃÏîÄ¿ÏÂ, ÓÐÒ»¸öjspÎļþ¼Ð 
¸ÃÎļþ¼ÐÏ°üÀ¨: 
login.jsp    // µÇ½ҳÃæ 
register.jps  // ×¢²áÒ³Ãæ 
ÎÒÃÇÔÚä¯ÀÀÆ÷ÖÐÊäÈëµØÖ· (×¢Òâ: µØÖ·µÄÄÚÈÝ): 
http://localhost:8080/MyApp/jsp/login.jsp 
Õâʱºò, ä¯ÀÀÆ÷»áÁ´½Óµ½ "µÇ½ҳÃæ" (login.jsp) 
ÔÚlogin.jspÎļþÄÚ°üº¬ÁËÈçÏ "²¿·Ö´úÂë": 
<a href="jsp/register.jsp">×¢²áÓû§ </a> 
ÄÇô,Èç¹ûÎÒÃǵã»÷Õâ¸öÁ´½Ó,¾Í»áÔÚä¯ÀÀÆ÷µØÖ·À¸ÖÐ, ³öÏÖÈçÏ´íÎóÁ´½Ó: 
http://localhost:8080/MyApp/jsp/jsp/register.jsp 
¿´~~ 
Ϊʲô»á³öÏÖ"/jsp/jsp/register.jsp"ÄØ? 
ÒòΪ, ÍøÒ³ÖеÄ"Ïà¶ÔÁ´½Ó", ÊÇÏà¶ÔÓÚÄãËù "ÇëÇóµÄURL·¾¶" Ëù¾ö¶¨µÄ. 
¼´: 
ÒòΪÕâÀïÇëÇ󷾶ÊÇ:http://localhost:8080/MyApp/jsp/login.jsp 
ÄÇô, ä¯ÀÀÆ÷ ¾Í»áÔÚÕâ¸ö·¾¶ÏÂ(¼´:http://localhost:8080/MyApp/jsp/)È¥ÕÒ jsp/register.jsp 
ËùÒԾͻá³öÏÖÈçÏ´íÎóÄÚÈÝ: 
http://localhost:8080/MyApp/jsp/jsp/register.jsp 
ÉÏÃæµÄÎÊÌ⣬¾ÍÊǵ÷ÓÃÒ³ÃæºÍ±»µ÷ÓÃÒ³ÃæµÄURL²»Í¬ËùÔì³ÉµÄ£¬ 
´ËÀà´íÎóÒ²³£³£»á³öÏÖÔÚ2¸öÒ³ÃæÖ®¼ä½øÐÐ "ת·¢"(forward) ²Ù×÷µÄʱºò¡£ 
ÒòΪforwardÊÇÔÚºǫ́½øÐеģ¬¶Ô¿Í»§¶ËÀ´ËµÊÇ͸Ã÷µÄ¡£(¼´: URL²»¸Ä±ä£¬¶øÊý¾ÝÄÚÈÝÈ´ÊÇÁíÒ»¸öÒ³Ãæ·µ»ØÀ´µÄ¡£¡£¡£) 
ÄÇôÈçºÎ½â¾öÕâÎÊÌâÄØ£¿ 
(Ò»)·½·¨Ò»£ºÖ±½Ó²ÉÓþø¶Ô·¾¶ (²»ÍƼö) 
ÔÚJSPÒ³Ãæ¶Ë£¬»ñµÃ±¾ÏîÄ¿µÄ¾ø¶ÔµØÖ·£¨Èç¹ûÄãµÄÏîÄ¿½ÐMyApp£¬ÄÇô»ñµÃµ½µÄµØÖ·¾ÍÊÇ http://localhost:8080/MyApp/£©: 
´úÂëÈçÏÂ: 
<!-- **************·½·¨Ò»***************** --> 
<%@ page language="java" pageEncoding="GBK" contentType="text/html;charset=gbk" isELIgnored="false"%> 
<% 
String path = request.getContextPath(); 
// »ñµÃ±¾ÏîÄ¿µÄµØÖ·(ÀýÈç: http://localhost:8080/MyApp/)¸³Öµ¸øbasePath±äÁ¿ 
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPo


Ïà¹ØÎĵµ£º

JSP¾Å¸öÄÚÖöÔÏó

ѧϰJ2EE£¬±ØÐë¶ÔÏÂÃæµÄ¼¸¸ö¶ÔÏóÓкÜÉîµÄÀí½â
1¡¢request   ->  javax.servlet.http.HttpServletRequestµÄʵÀý
     ¸Ã¶ÔÏó·â×°ÁËÒ»´ÎÇëÇ󣬿ͻ§¶ËµÄÇëÇó²ÎÊý¶¼±»·â×°ÔڸöÔÏóÀï¡£ÕâÊÇÒ»¸ö³£ÓõĶÔÏ󣬻ñÈ¡¿Í»§¶ËÇëÇó²ÎÊý±ØÐëʹÓøöÔÏó¡£³£Óõķ½·¨ÓÐgetParameter(String pa ......

jspÁ¬½Ósql server2005



jspÁ¬½Ósql server2005
£¨¾­²âÊÔÁ¬½Ó³É¹¦£©
  ½Ó´¥Java»òÕßJSP£¬ÄÑÃâ»áʹÓõ½Êý¾Ý¿â
SQL Server
2000/2005£¨ÎÒʹÓÃ2005±ê×¼°æ[9.0.3054]²âÊÔ£©£¬¾­¹ý×Ô¼ºµÄËÑË÷ºÍÑо¿£¬Ê¹ÓÃJDBCÁ¬½ÓSQL
Server³É¹¦£¬ÌØ´ËÕûÀí·½·¨£¨Ê¹ÓÃEclipse 3.2£©ÈçÏ¡£
×¼±¸¹¤×÷
Ê×ÏÈ£¬²Ù×÷ϵͳ
Öа²×°ºÃSQL Server
2000/2005£¬È ......

jspÇå³ýÒ³Ãæsession¡¢cookies»º´æ

Ò»¡¢Çå³ýÒ³Ã滺´æ
ÔÚjspÒ³Àï
<%response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires", 0);
response.flushBuffer();%>
ÔÚhtmlÒ³Àï
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<META HTTP-EQUI ......

JSPѧϰ£¨Ò»£©

JSP»ù±¾Óï·¨
´ó²¿·ÖJSP±»Ò»¸öÒÔ“<%” ¿ªÍ·ºÍÒÔ“%>”½áβµÄµÄ±ê¼ÇÀ¨ÔÚÆäÖС£ÔÚ¸üеÄJSP 1.1¹æ·¶³ǫ̈ºó£¬¾ÍÓÐÁËÓëXML¼æÈݵİ汾¡£
JSPÖ¸ÁîºÍ½Å±¾ÔªËØ
Directives <%@ directive %>
Declarations <%! declaration %>
Expressions <%= expression %>
Code Fragment/ ......

jspµÄpageEncodingºÍcontentType

pageEncodingÊÇjspÎļþ±¾ÉíµÄ±àÂë
contentTypeµÄcharsetÊÇÖ¸·þÎñÆ÷·¢Ë͸ø¿Í»§¶ËʱµÄÄÚÈݱàÂë
JSPÒª¾­¹ýÁ½´ÎµÄ“±àÂ딣¬µÚÒ»½×¶Î»áÓÃpageEncoding£¬µÚ¶þ½×¶Î»áÓÃutf-8ÖÁutf-8£¬µÚÈý½×¶Î¾ÍÊÇÓÉTomcat³öÀ´µÄÍøÒ³£¬ ÓõÄÊÇcontentType¡£
µÚÒ»½×¶ÎÊÇjsp±àÒë³É.java£¬Ëü»á¸ù¾ÝpageEncodingµÄÉ趨¶ÁÈ¡jsp£¬½á¹ûÊÇ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ