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

JSP»ù´¡ÖªÊ¶


JSPԭʼ´úÂëÖаüº¬ÁËJSPÔªËØºÍTemplate(Ä£°å) dataÁ½Àà 
Template dataÖ¸µÄÊÇJSPÒýÇæ²»´¦ÀíµÄ²¿·Ö£¬¼´±ê¼Ç<%……%>ÒÔÍâµÄ²¿·Ö£¬
ÀýÈç´úÂëÖеÄHTMLµÄÄÚÈÝµÈ £¬ÕâЩÊý¾Ý»áÖ±½Ó´«Ë͵½¿Í»§¶ËµÄä¯ÀÀÆ÷
JSPÔªËØÔòÊÇÖ¸½«ÓÉJSPÒýÇæÖ±½Ó´¦ÀíµÄ²¿·Ö£¬ÕâÒ»²¿·Ö±ØÐë·ûºÏJSPÓï·¨£¬
·ñÔò»áµ¼Ö±àÒë´íÎó¡£
¶¯Ì¬µÄJava´úÂë(±ØÐë°üº¬ÔÚÌØ¶¨µÄ±êÇ©ÖУ©
1.JSP±ê×¼Ö¸Áî
2.JSP³ÌÐò´úÂëÔªËØ
3.JSP±ê×¼¶¯×÷
4.±êÇ©¿â
1)±ê×¼Ö¸ÁîÓÃÀ´É趨JSPÍøÒ³µÄÕûÌåÅäÖÃÐÅÏ¢JSPÖеÄÈ«¾Ö±äÁ¿£¬ÉùÃ÷À࣬ҪʵÏֵķ½·¨ºÍÊä³öÄÚÈݵÄÀàÐ͵È
ÌØµã:ËüÃDz¢²»Ïò¿Í»§¶Ë²úÉúÈκÎÊä³ö£¬
ËùÓеÄÖ¸ÁîÔÚJSPÕû¸öÎļþ·¶Î§ÄÚÓÐЧ
Ϊ±àÒëÒë½×¶ÎÌṩÁËÈ«¾ÖÐÅÏ¢
ÈýÖÖ±ê×¼Ö¸Á
1.page£ºÉ趨JSPÕûÌåÐÅÏ¢
ÓÃÓÚ¶¨ÒåJSPÒ³ÃæµÄ¸÷ÖÖÊôÐÔ£¬ÎÞÂÛpageÖ¸Áî³öÏÖÔÚJSPÒ³ÃæÖеÄʲôµØ·½£¬
Ëü×÷ÓõͼÊÇÕû¸öJSPÒ³Ãæ£¬ÎªÁ˱£³Ö³ÌÐòµÄ¿É¶ÁÐÔºÍ×ñÑ­Á¼ºÃµÄ±à³Ìϰ¹ß£¬
pageÖ¸Áî×îºÃÊÇ·ÅÔÚÕû¸öJSPÒ³ÃæµÄÆðʼλÖá£
2.include£ºÔÚJSPÄÚ°üº¬ÆäËûJSPÄÚÈÝ
ÓÃÓÚ֪ͨJSPÒýÇæÔÚ·­Ò뵱ǰJSPÒ³ÃæÊ±½«ÆäËûÎļþÖеÄÄÚÈݺϲ¢½øµ±Ç°JSPÒ³Ãæ×ª»»³ÉµÄServletÔ´ÎļþÖУ¬
ÕâÖÖÔÚÔ´Îļþ¼¶±ð½øÐÐÒýÈëµÄ·½Ê½³ÆÖ®Îª¾²Ì¬ÒýÈ룬
µ±Ç°JSPÒ³ÃæÓ뾲̬ÒýÈëµÄÒ³Ãæ½ôÃܽáºÏΪһ¸öServlet¡£
×¢Ò⣺
³ýÁËimportºÍpageEncodingÊôÐÔÖ®Í⣬pageÖ¸ÁîµÄÆäËûÊôÐÔ²»ÄÜÔÚÕâÁ½¸öÒ³ÃæÖÐÓв»Í¬µÄÉèÖÃÖµ
Óï·¨£º
<%@ include file="relativeURL"%>
fileÊôÐÔµÄÉèÖÃÖµ±ØÐëʹÓÃÏà¶Ô·¾¶£¬Èç¹ûÒÔ“/”¿ªÍ·£¬
±íʾÏà¶ÔÓÚµ±Ç°WEBÓ¦ÓóÌÐòµÄ¸ùĿ¼£¨×¢Òâ²»ÊÇÕ¾µã¸ùĿ¼£©£¬
·ñÔò£¬±íʾÏà¶ÔÓÚµ±Ç°Îļþ¡£
3.taglib£ºÔÚJSPÄÚʹÓÓ×Ô¶¨Òå±êÇ©”£¬ÕâÖÖ·½Ê½¸ü¼ÓÁé»î


Ïà¹ØÎĵµ£º

struts2ÖÐactionÈçºÎ»ñÈ¡jspÒ³Ãæ²ÎÊý


1. ActionContext
ÔÚStruts2¿ª·¢ÖÐ,³ýÁ˽«ÇëÇó²ÎÊý×Ô¶¯ÉèÖõ½ActionµÄ×Ö¶ÎÖÐ,ÎÒÃÇÍùÍùÒ²ÐèÒªÔÚActionÀïÖ±½Ó»ñÈ¡ÇëÇó(Request)»ò»á»°
(Session)µÄһЩÐÅÏ¢,ÉõÖÁÐèÒªÖ±½Ó¶ÔJavaServlet
HttpµÄÇëÇó(HttpServletRequest),ÏìÓ¦(HttpServletResponse)²Ù×÷.
ÎÒÃÇÐèÒªÔÚActionÖÐÈ¡µÃrequestÇëÇó²ÎÊý"username"µÄÖµ: ......

ÈçºÎÈ¥³ýJSPÊä³öHTMLʱ²úÉúµÄ´óÁ¿¿Õ¸ñºÍ»»ÐÐ

ÔÚWEBÓ¦ÓÃÖÐ,Èç¹ûʹÓÃjsp×÷Ϊview²ãµÄÏÔʾģ°å,¶¼»á±»¿Õ¸ñ/¿Õ»»ÐÐÎÊÌâËùÀ§ÈÅ.
Õâ¸öÎÊÌâµ±ÄêÒ²À§ÈÅÁËÎұȽϳ¤µÄʱ¼ä.ÒòΪÔÚjspÄÚʹÓõÄEL±êÇ©ºÍÆäËû±êǩʱ,»á²úÉú´óÁ¿µÄ¿Õ¸ñºÍ»»Ðзû.ÀýÈç:
------- start ----------
<c:choose>
    <c:when test="${fn:length(mainPageList)>1&}&q ......

jspÒ³Ãæ´«ÖµµÄÂÒÂëÎÊÌâµÄ½â¾ö

jspÒ³ÃæÖ®¼äµÄ´«ÖµÂÒÂëÎÊÌ⣬×ܽáÈçÏ£º
a.jspÍùb.jsp´«Öµ£º
a.jspÒ³ÃæÄÚÈÝ£º
<%@ page language="java" import="java.util.*" pageEncoding="GB2312"%>
<form action="b.jsp">
      name:<input type=text name=name>
      <input type=s ......

jsp servlet ÖÐsetAttribute()ºÍgetParameter()Çø±ð

setAttribute()ÊÇÓÃÓÚ·þÎñÆ÷¶ËÉèÖÃÊôÐÔÏò¿Í»§¶Ë·¢Ë͸ÃÊôÐÔ£¬ÔÚ¿Í»§¶Ëͨ¹ýgetAttribute£¨£©»ñµÃÊôÐÔ¡£setAttribute()Ò²ÄÜ´«µÝ¶ÔÏó¡£
setParameter()Êǿͻ§¶ËÏò·þÎñÆ÷¶Ë·¢ËÍÊôÐÔ£¬Ö»ÄÜ´«×Ö·û£¬ÓÃÓÚget/postµÄÊýÖµ´«µÝ£¬ÔÚ·þÎñ¶ËÓÃgetParameter£¨£©»ñÈ¡£¬Ò³ÃæÖÐÓÐforward´Ó¶¨ÏòÒ³ÃæµÄµØÖ·ÖеIJÎÊýÒ²ÄÜÓÃgetParameter£¨£©»ñÈ¡¡ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ