Why does struts iterate inserts blank lines in the source code?
I have this code:
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<% List<String> years = new ArrayList<String>(); %>
<logic:iterate name="ActiviteHolidayForm" property="holidayDays" id="line">
<%
if(!years.contains(line.toString().split("-开发者_如何转开发")[0]))
years.add(line.toString().split("-")[0]);
%>
</logic:iterate>
The problem is that this code inserts a huge number of blank lines in the source code (I suppose equal to the times the code iterates). Is there a way to avoid this? I mention that I have a single line before and after this code. Thanks!
Summary of New Features in JSP 2.1 Technology:
Removing Blank Lines: TrimWhiteSpace
Can be done by inserting <%@page trimDirectiveWhitespaces="true"%>
in your JSP
or by inserting the following part in your web.xml (Servlet 2.5 XSD):
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<trim-directive-whitespaces>true</trim-directive-whitespaces>
</jsp-property-group>
</jsp-config>
Struts is not inserting blank lines; you are inserting blank lines. Answer this question and you will understand why: "What characters do you have between %> and </logic:iterate>?"
精彩评论