【发布时间】:2015-03-12 11:04:19
【问题描述】:
我在删除 JSP 文件中的前导空格/空格和空行时遇到问题。为了减少每个 jsp 文件的大小,我在构建项目时应该删除这些无用的空白。
Maven 用于构建项目。是否有可能在所有 jsp 文件中删除它(例如使用正则表达式)?到目前为止,我还没有发现任何可能性。
我发现的唯一一件事是在 jsp 文件中删除带有 trimDirectiveWhitespaces 的指令空格,但这并没有删除前导空格。
对于编程,需要对这些格式有一个很好的了解,但如果编译器(或预编译器)可以在.war 文件中删除它,那就太好了。
一个例子:
文件:
<div class="half left">
<h2>Contact</h2>
<table>
<tr>
<th>Name:</th>
<td>${person.firstname} ${person.surname}</td>
</tr>
<tr>
<th>Tel:</th>
<td>${person.phone}</td>
</tr>
<tr>
<th>Fax:</th>
<td>${person.fax}</td>
</tr>
<tr>
<th>E-Mail:</th>
<td><a href="mailto:${person.email}">${person.email}</a></td>
</tr>
</table>
</div>
编译后.war中的文件:
<div class="half left">
<h2>Contact</h2>
<table>
<tr>
<th>Name:</th>
<td>${person.firstname} ${person.surname}</td>
</tr>
<tr>
<th>Tel:</th>
<td>${person.phone}</td>
</tr>
<tr>
<th>Fax:</th>
<td>${person.fax}</td>
</tr>
<tr>
<th>E-Mail:</th>
<td><a href="mailto:${person.email}">${person.email}</a></td>
</tr>
</table>
</div>
如果有人有想法(可能直接在pom.xml?)感谢您的回复。
【问题讨论】: