为什么struts迭代会在源代码中插入空行?
我有这段代码:
<%@ 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>
问题是这段代码在源代码中插入了大量的空行(我想等于代码迭代的次数)。有办法避免这种情况吗?我提到我在这段代码之前和之后都有一行。谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
JSP 2.1 技术新功能摘要:
删除空行:
TrimWhiteSpace
可以通过在您的
JSP
或在 web.xml (Servlet 2.5 XSD) 中插入以下部分:Summary of New Features in JSP 2.1 Technology:
Removing Blank Lines:
TrimWhiteSpace
Can be done by inserting
<%@page trimDirectiveWhitespaces="true"%>
in yourJSP
or by inserting the following part in your web.xml (Servlet 2.5 XSD):Struts 不插入空行;您正在插入空行。回答这个问题,你就会明白为什么:“%> 和 之间有什么字符?”
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>?"