jspÖеÄ×Ô¶¨Òå±êÇ©µÄÓ÷¨
±àд×Ô¶¨Òå±êÇ©²½Öè
±àд±êÇ©´¦ÀíÆ÷£¨´¦Àí±êÇ©µÄJavaÀࣩ£¬ÕâЩÀàÐèҪʵÏÖһЩ¹æ·¶»¯µÄ±êÇ©½Ó¿Ú
±àд±êÇ©¿âÃèÊöÎļþ£¨TLD£©£¬Õâ¸öÎļþÃèÊöÁËÿ¸ö±êÇ©ºÍ¶ÔÓ¦µÄJava±êÇ©´¦ÀíÆ÷ÀàÖ®¼äµÄÓ³Éä¹Øϵ
ÔÚweb.xmlÖÐÅäÖñêÇ©¿âÎļþµÄURI
ÔÚJSPÒ³ÃæÖÐÀûÓÃtaglibÖ¸Á±êÇ©¿âÒýÈëµ½Ò³ÃæÖÐ
¾ßÌåÄÚÈݲο¼¿Î¼þÁË¡£Ö»ËµÒ»Ð©×¢ÒâµÄµØ·½£º
¶¨Òå±êÇ©µÄ´¦ÀíµÄÊÇÒ»¸öÀ࣬¶ø²»ÊÇÒ»¸öservlet£¬ËùÒÔн¨µÄʱºòÔÚMyEclipseÖÐÑ¡Ôñн¨Ò»¸öclass£¬²¢ÇÒ×¢ÒâÒ»¶¨Òª·ÅÔÚÒ»¸ö°üÀ²»ÄÜÖ±½ÓÓÃdefaultpackage,ÏÖÔÚ»¹²»ÖªµÀ½â¾ö°ì·¨¡£
Õû¸ö¹ý³ÌÊÇÕâÑùµÄ£º
jspÖÐʹÓñêÇ©£¬µ±Ò³Ãæ·¢ÏÖ²»ÄÜÔÚĬÈϵıêÇ©¿âÖÐÕÒµ½µÄʱºò£¬»á²éÕÒ<%@ taglib uri="tagliburi" prefix="taglibprefix" %>
È»ºó»áµÃµ½´¦ÀíÕâ¸ö±êÇ©µÄ¶ÔÓ¦µÄtagliburi£¬
ÔÚweb.xmlÖÐÕÒµ½´¦ÀíÕâ¸öuri¶ÔÓ¦µÄtaglib.tld,
<taglib>
<taglib-uri>/mytaglib</taglib-uri>
<taglib-location>/WEB-INF/lib/mytaglib.tld</taglib-location>
</taglib>
ÔÚÕâ¸ötldÖÐÕÒµ½´¦ÀíÕâ¸ö±êÇ©µÄÀ࣬
<tag>
<name>tagname</name><!-- Õâ¸öÊDZêÇ©Ãû--!>
<tag-class>package.class</tag-class><!--Õâ¸öÊǶÔÓ¦µÄ´¦ÀíµÄÀà¡£--!>
<attribute><!--ÕâÊÇ´«µÝµÄ²ÎÊý--!>
<name>color</name>
<requried>false</requried>
</attribute>
</tag>
È»ºó½«²ÎÊýÌá½»¸øÕâ¸öÀ࣬Õâ¸öÀà×ö³öÏàÓ¦µÄ´¦Àí¡£
×îºóΪÌåÏÖÔÚwebÒ³ÃæÉÏ£¬ÊǾ¹ýת»¯µÄhtml±ê¼Ç¡£Àý£¬ÂÔ¡£
Ïà¹ØÎĵµ£º
½ñÌì²âÊÔÈËÔ±¸øÎÒÌáÁËÒ»¸öbug£¬ËµÎÒ¿ª·¢µÄÄ£¿é±¨¿ò¼ÜµÄjs´íÎ󣬵±Ê±Ò»Ìý¾ÍãÂÁË£¬ÎÒ±¾µØ²âÊÔÍêȫûÎÊÌ⣬ÔõôÉÏÁË·þÎñÆ÷»á³öÏÖÕâ¸öÎÊÌâÄØ£¿
ÓÚÊÇÎÒÈ¥·þÎñÆ÷ÉϲâÁËÒ»ÏÂ×Ô¼ºÐ´µÄÄǸöÄ£¿é£¬½á¹û±¨µÄ´íÎ󻹺ͲâÊÔÈËÔ±Ìá¸øÎҵĴíÎó²»Ò»Ö£¬ÔÓ»ØÊ£¿ÓÚÊÇÎÒÓÖÕÒµ½Ò»ÃûͬÊ£¬ÈÃËû°ïÎÒ²âһϣ ......
ʵÑ鱨¸æ
Ò». »ù±¾Ë¼Â·¼°ÊµÑé½á¹û£¨¼Ç¼¸÷ÖÖÔËÐÐÇé¿ö»òÒ³ÃæµÄÔËÐÐЧ¹û£©£»
1¡¢Ê¹ÓÃTOMCAT·þÎñÆ÷ÅäÖÃjspÓ¦ÓÃ
1£©´ò¿ªTOMCAT/webapps×ÓĿ¼£¬´´½¨Ò»webÓ¦Óã¨Èçmyweb£©£¬½«example0.jspÓëexample1.jspÎļþ¸´ÖÆÈëÄÚ£¬²¢ÔÚ¸ÃĿ¼ÏÂÉèÖÃWEB-INFĿ¼¼°web.xmlÅäÖÃÎļþ£»
2£©ÔÚä¯ÀÀÆ÷µØÖ·À¸ÊäÈëhttp://localhost:8080/myweb/ex ......
<%@page import="com.opensymphony.xwork2.util.ValueStack"%><%
ValueStack vs = (ValueStack)request.getAttribute("struts.valueStack");
String aa = (String)vs.findValue("downloadContent");
response. ......
tomcat ĬÈÏʹÓõÄ×Ö·û¼¯ÊÇISO-8859-1£¬²»Ö§³ÖÖÐÎÄ×Ö·û£¬ËùÒÔÔÚÏÖʵÖÐÎÄʱÐèҪת»»×Ö·ûºÍÉèÖÃ×Ö·û¼¯¡£
server.mxl¸ÄΪ<Connector port="8080" protocol="HTTP/1.1" maxThreads="150" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" /> £¬Ìí¼Ó´úÂëת»»×Ö·ûString.getBytes("ISO-8859-1"),"UTF-8 ......