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

JSP,servletµÄÏà¶Ô·¾¶ÎÊÌâ

Ç°Ì᣺¼ÙÉèÄãµÄ Http µØַΪ http://192.168.0.1/ ÄãµÄ web Ó¦ÓÃΪ webapp £¬ÄÇôÄãµÄ web Ó¦Óà URL Ϊ http://192.168.0.1/webapp/
[ÎÊÌâ1]
[ÃèÊö]µ±ÔÚ jsp ÖÐÒýÈë css ʱ£¬Èç¹ûÆäÏà¶Ô·¾¶Ïà¶ÔÓÚµ±Ç° jsp ÎļþµÄ£¬¶øÔÚÒ»¸öºÍÕâ¸ö jsp µÄ·¾¶²»Ò»ÑùµÄ servlet ÖÐ forwarder Õâ¸ö jsp ʱ£¬¾Í»á·¢ÏÖÕâ¸ö css Ñùʽ¸ù±¾Ã»ÓÐÆð×÷Óá£
[·ÖÎö]ÕâÊÇÒòΪÔÚ servlet ÖÐת·¢Ê± css µÄ·¾¶¾ÍÊÇÏà¶ÔÓÚÕâ¸ö servlet µÄÏà¶Ô·¾¶¶ø·Ç jsp µÄ·¾¶ÁË¡£ËùÒÔÕâʱºò²»ÄÜÔÚ jsp ÖÐÓÃÕâÑùµÄ·¾¶£º <link href="one.css" rel="stylesheet" type="text/css"> »òÕß <link href="../../one.css" rel="stylesheet" type="text/css"> ÀàËÆ href="one.css" ºÍ ../../one.css µÄ html Ïà¶Ô·¾¶ÊÇÏà¶ÔÓÚÒýÓÃÕâ¸ö css µÄÎļþµÄÏà¶Ô·¾¶¡£¶øÔÚ servlet ÖÐת·¢Ê±¾ÍÊÇÏà¶ÔÓÚÕâ¸ö servlet µÄÏà¶Ô·¾¶ÁË£¬ÒòΪ jsp ·¾¶ºÍ servlet ·¾¶ÊDz»Ò»ÑùµÄ£¬ËùÒÔÕâÑùµÄÒýÓÿ϶¨Êdzö´íµÄ¡£
[½â¾ö]ËùÒÔÕâ¸öʱºò£¬ÒªÓÃÕ¾µã¸ùĿ¼£¬¾ÍÊÇÏà¶ÔÓÚ http://192.168.0.1/ µÄĿ¼£¬ÒÔ“ / ”¿ªÍ·¡£
Òò´ËÉÏÊö´íÎóÓ¦¸üÕýΪ href=”/webapp/one.css” ÀàËƵÄÕ¾µã¸ùĿ¼µÄÏà¶ÔĿ¼¡£ÕâÑùÔÚ servlet ת·¢ºóºÍ jsp Öж¼ÊÇÏà¶ÔÓÚÕ¾µã¸ùĿ¼µÄÏà¶Ô·¾¶£¬¾ÍÄÜÕýȷʹÓÃËù¶¨ÒåµÄ css ÑùʽÁË¡£
[ÎÊÌâ2]
ÔÚMyEclispeÖеÄJSPµÄÁ½ÖÖÄ£°å,Ò»ÖÖÊÇAdvanced,Ò»ÖÖÊÇBasic
  Á½ÕßµÄÇø±ðÒ²»áÉæ¼°µ½Â·¾¶ÎÊÌâ,ÈçͼƬµÄ·¾¶,Á´½ÓµÄ·¾¶
 
  Advanced TemplateÖÐÒ³ÃæµÄ´úÂë¶àÁËÒÔÏ´úÂë:
  <%
      String path = request.getContextPath();
      String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
  %>
   <base href="<%=basePath%>">
ÆäÖÐ<base href="<%=basePath%>">±ØÐë·ÅÔÚ<head></head>ÖÐ
Õâ¶Î´úÂëµÄ×÷ÓÃÊÇÉèÖûù´¡Â·¾¶µÄ,basepathΪ±äÁ¿.<base href="">±êÇ©µÄÓô¦Êǽâ¾ö±à³ÌʱºòµÄÏà¶Ô·¾¶ÎÊÌâ.
ÉèÖÃÁË<base href="<%=basePath%>">
Ò³ÃæÉÏͼƬ,Á´½ÓµÄ·¾¶Ö¸µÄ¶¼Êǵ±Ç°Ó¦ÓóÌÐòµÄ¸ù·¾¶ÏÂ.
µ±È»£¬Õâ¸öbase»¹ÓÐÒ»¸öÓ÷¨£¬ÈçÔÚhead²¿·Ö¼ÓÉÏÕâôһÐУº <base href="_blank"> £¬¾ÍÊÇĬÈÏËùÓÐÁ´½ÓÔÚд°¿Ú´ò¿ª


Ïà¹ØÎĵµ£º

JSP 9´ó¶ÔÏóÏê½â

ѧϰJSPÖ÷ҪѧϰËûµÄ9´ó¶ÔÏó(request, response, pageContext, session, application, out, config, page, exception ),ÕâЩ¶ÔÏó¶¼ÊǾ²Ì¬¶ÔÏ󣬲»Óö¨Òå¾Í¿ÉÒÔÖ±½ÓʹÓ㬰ÑËûÃǶ¼Á˽âÇå³þ²¢»áÔËÓ㬾ͿÉÒÔÔÚ¼òÀúÉÏÌíÉÏÒ»¸öÊìϤ¼¼ÄÜ:JSP
JspÄÚÖöÔÏó ¹¦ÄÜ Ö÷Òª·½·¨
out  Ïò¿Í»§¶ËÊä³öÊý¾Ý print() println() flush() ......

jspÖÐ×Ô¶¨Òå±êÇ©×ܽá(Ò»)_´«Í³±êǩƪ

×Ô¶¨Òå±êÇ©ÊÇÈÿª·¢ÈËÔ±´´½¨¿Í»§»¯µÄ±êÇ©,²¢ÇÒÔÚjspÎļþÖÐʹÓÃÕâЩ±êÇ©,ÕâÑù¿ÉÒÔʹjsp´úÂë¸ü¼ò½à!
 Ê×ÏÈÕâÀïÏȽéÉÜ´Ó¶¨Òå±êÇ©µ½Ê¹ÓñêÇ©µÄ²½Öè:
     1,´´½¨×Ô¶¨Òå±êÇ©´¦ÀíÀà,¼°Ïà¹ØÀà.class ²¢ÇÒ°ÑËûÃǶ¼·ÅÔÚWEB-INF/classesĿ¼ÏÂ
     2,´´½¨TLD±êÇ©¿âÃèÊöÎļþ(.tld)Î ......

jsp URI´«µÝ²ÎÊý£¬¶Ô·½½ÓÊÜÊÇÂÒÂë½â¾ö·½·¨

ÕâÖ÷ÒªÊÇtomcatµÄÎÊÌ⣬Ëü»áÔÚ´«Ë͵Äʱºò°Ñ×Ö·û¼¯ÖØбàÒ룬µÈ´«¹ýÈ¥µÄjspÒ³Ãæ½ÓÊܵÄʱºò¾Í»á³öÏÖÂÒÂ룬
²»¹ÜÔÚÒ³ÃæÀïÈçºÎÉèÖÃ×Ö·û¼¯¶¼Ã»°ì·¨½â¾ö£¬Õâʱºò±ØÐë±ØÐëÔÚtomcat°²×°Ä¿Â¼Àï½øÐÐÉèÖã¬
C:\Program Files\apache-tomcat-6.0.14\confĿ¼Ï server.xmlÏ <Connector/>±êÇ©Ï ¼ÓÒ»¾ä URIEncoding="GBK" ¾ÍºÃÁ ......

JSPÖÐÓë·¾¶Ïà¹ØµÄ³£Óõļ¸¸ö·½·¨


http:/localhost/123/jsp/test.jsp:
<%@ page language="java" pageEncoding="UTF-8"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logi ......

¹ØÓÚÍøÕ¾Ê×Ò³Ãû³Æ°²È«ÐÔÎÊÌâ JSP ÔÊÐíĿ¼ä¯ÀÀ

ÔÚ²»ÔÊÐíĿ¼ä¯ÀÀµÄÇé¿öÏ     ä¯ÀÀÆ÷»áÏÈÕÒµ½Ê×Ò³£¨Ä¬ÈÏΪindex.html  /index.jsp...£©
·ñÔò³ö´í
Òò´Ë ÈôÊ×Ò³±»¶ñÒâ¸ü¸Ä   ÍøÕ¾±ÀÀ£
½â¾ö·½·¨£º
¸ü¸ÄĬÈÏÆô¶¯Ò³Ã棺$tomcat/conf/web.xml×îºóλÖÃ
<welcome-file-list>
<welcome-file>index.html</welcome-file> ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ