dz̸ÈçºÎɾ³ýJSP±àÒëºóµÄ¿ÕÐÐ
µ±ÄãÔÚ¿Í»§¶ËÓÃview source¿´JSPÉú³ÉµÄ´úÂëʱ£¬»á·¢ÏÖÓкܶà¿ÕÐУ¬ËûÃÇÊÇÓÉ< %...% >ºóµÄ»Ø³µ»»ÐжøÉú³ÉµÄ£¬Ò²¾ÍÊÇ˵ÿһÐÐÓÉ< %...% >°üº¬µÄJSP´úÂëµ½¿Í»§¶Ë¶¼±ä³ÉÒ»¸ö¿ÕÐУ¬ËäÈ»²»Ó°Ïìä¯ÀÀ£¬µ«»¹ÊÇÏ£ÍûÄÜ°ÑËûÃÇɾµô¡£ÕâÀォΪ´ó¼Ò½éÉÜÈçºÎɾ³ýJSP±àÒëºóµÄ¿ÕÐС£
Tomcatɾ³ýJSP±àÒëºóµÄ¿ÕÐа취ÈçÏ£º
1. Ö§³ÖJSP 2.1+ £¬ÔÚÿ¸öҪȥ¿ÕÐеÄÒ³ÃæÀï°üº¬ÏÂÃæ´úÂ룺
<%@ page trimDirectiveWhitespaces="true" %>
ÔÚ Tomcat 6.0.14ϲâÊÔJSP±àÒë³É¹¦
2. Ö§³Öservlet 2.5+, ¼´ web.xmlµÄ XSD°æ±¾Îª2.5£¬ÔÚweb.xmlÖмÓÈëÈçÏ´úÂë
<jsp-config> <jsp-property-group> <url-pattern>*.jsp</url-pattern> <trim-directive-whitespaces>true</trim-directive-whitespaces> </jsp-property-group> </jsp-config>
ÔÚtomcat 6.0.14ϲâÊÔJSP±àÒë³É¹¦
3. Tomcat 5.5.x+£¬ÔÚTomcat°²×°Ä¿Â¼/conf/web.xmlÖÐÕÒµ½Ãû½Ð"jsp"µÄservlet£¬Ìí¼ÓÏÂÃæÒ»¶Î´úÂ룺
<init-param> <param-name>trimSpaces</param-name> <param-value>true</param-value> </init-param>
±¾ÈËû²â¹ý£¬²»¹ýtomcatÖÐweb.xmlÎļþµÄ°ïÖúÕâô˵µÄ
trimSpaces Should white spaces in template text between actions or directives be trimmed? [false]
ÔÚʵ¼Ê²Ù×÷ÖÐÎÒ¼ÓÈëÁË5.5µÄÅäÖõ½Ò³ÃæÖв¢·´¸´Æô¶¯Á˼¸´Îtomcatµ«ÊÇ»¹ÊÇûÓгɹ¦£¬ºóÀ´²ÅÏëµ½JSPÒѾ±àÒë³ÉservletÁËËùÒÔûÓÐÄܸı䣬½øÈëµ½tomcatÖеÄworkĿ¼°ÑÒѾ½øÐÐJSP±àÒëµÄclassÈ«²¿É¾³ý£¬ÍÛ¹þ¹þ£¬Õû¸öÊÀ½çÇå¾»ÁË£¬³É¹¦É¾³ý¿ÕÐÐ
resinɾ³ýJSP±àÒëºóµÄ¿ÕÐа취ÈçÏ£º
I'm getting a lot of whitespace in my JSP that I don't intend to be there. Why is it appearing and how can I get rid of it?
The extra whitespace is coming from newlines, often at the end of declaration lines at the beginning of the JSP. For example, the following jsp:
<%@ page import='java.util.*' %>
<%@ page import='java.io.*' %>
Hello world
Has newlines in these locations:
<%@ page import='java.util.*' %>NL
<%@ page import='jav
Ïà¹ØÎĵµ£º
ÓеÄʱºò»áÍü¼Ç£¬¼Ç¼һÏ£º
<iframe id="xx" name="xx" width="515" height="177" scrolling="no" border="0" marginwidth="0" marginheight="0" frameborder="0" src="Xx.jsp"></iframe>
Ҫʹjsp²»±äÐΣ¬Ö÷ÒªÊÇmarginwidth="0" marginheight="0"Á½¸öÊôÐÔ¡£ ......
Êý¾Ý¿âÓ¦ÓÃϵͳ°üÀ¨Êý¾Ý¿â£¬Êý¾Ý¿â¹ÜÀíϵͳ£¬Êý¾Ý¿âÓ¦ÓÃÈý´ó²¿·Ö¡£
ÊÀ½çÉÏ´æÔÚÐí¶àÍêÈ«²»Í¬µÄ¿Í»§Æ½Ì¨£¬ÔÚ²»Í¬Æ½Ì¨¼ä½»»»Êý¾Ý£¬ÐèÒª±£Ö¤Êý¾ÝµÄÍêÕûºÍ·þÎñµÄ¸ßЧ£¬Êý¾Ý¸ñʽµÄת»»ÎÊÌâÍùÍù³ÉΪÖÆÔ¼Web ServiceµÄÆ¿¾±£¬²ÉÓÃXML×÷ΪÊý¾Ý½»»»µÄ±ê×¼£¬¿ÉÒÔʹ¸÷¸öÒ칹ƽ̨ºÍ¸÷ÖÖ¸ñʽµÄÊý¾Ý½øÐÐÊý¾Ý½»»»³ÉΪ¿ÉÄÜ¡£
......
http://www.blogjava.net/19851985lili/articles/97664.html
ÄãµÄ´úÂë±¾ÉíÓÐÎÊÌ⣬һ°ãÀ´Ëµ£¬ÎÒÃÇÔÚʹÓÃStrutsʱ£¬Èç¹ûÒªÔÚJSPÒþʽµÄ´«Öµ¸øActionÓÐÁ½ÖÖÇé¿ö£º
1¡¢Òª´«µÄÖµÊÇfromBeanÖеÄÒ»¸ö×ֶΣ¬Äã˵µÄÇé¿öÓ¦¸Ã¾ÍÊÇÕâÖÖÇé¿ö£¬ÀýÈçÐèÒªÔÚEditÒ³ÃæÖб£´ætheID£¬ÔÚActionÖÐÖ´ÐÐUpdate²Ù×÷ʱ¸ù¾ÝIDÀ´¸üÐÂÊý¾Ý¿âµÄÖµ£¬Äã¿ÉÒ ......
Ò»¼ò½é£¬
Pager-taglib£¬Ö§³Ö¶àÖÖ·ç¸ñµÄ·ÖÒ³ÏÔʾ¡£Êµ¼ÊÉÏËýÊÇÒ»¸öJsp±êÇ©¿â£¬ÎªÔÚJSPÉÏÏÔʾ·ÖÒ³ÐÅÏ¢¶øÉè¼ÆµÄÒ»Ì×±êÇ©£¬Í¨¹ýÕâЩ±êÇ©µÄ²»Í¬µÄ×éºÏ£¬»áÐγɶàÖÖ²»Ò»ÑùµÄ·ÖÒ³Ò³Ã棬·ç¸ñ¸÷Ò죬Ëý×Ô´øµÄDEMO¾ÍÓÐÆßÖÖ×óÓҵķÖÒ³·ç¸ñ£¬°üÀ¨GoogleµÄ·ÖÒ³·ç¸ñ¡£¶øÐèÒª¶©ÖÆ×ÔÒѵķç¸ñµÄ·ÖÒ³Ò³ÃæÒ²·Ç³£¼òµ¥¡£
·ÖÒ³·½Ê½ÓÐÁ½ÖÖ£º
Ò ......