Strip whitespace from jsp output

There is a trimWhiteSpaces directive that should accomplish this,

In your JSP:

<%@ page trimDirectiveWhitespaces="true" %>

Or in the jsp-config section your web.xml (Note that this works starting from servlet specification 2.5.):

<jsp-config>
 
<jsp-property-group>
   
<url-pattern>*.jsp</url-pattern>
   
<trim-directive-whitespaces>true</trim-directive-whitespaces>
 
</jsp-property-group>
</jsp-config>

Unfortunately if you have a required space it might also need strip that, so you may need a non-breaking space in some locations.

posted @ 2012-09-22 17:17  庚武  Views(270)  Comments(0Edit  收藏  举报