The example of this article describes the method of removing blank lines by JSP programming. Share to everyone for your reference, specific as follows:
JSP because of the introduction of package commands and other processing, rendering the page source code a lot of line wrapping.
There used to be many ways to solve it, such as
1, in the source code to note the format, multiline and one line. This writing is more troublesome, the source code is not good-looking.
2. Write your own label and remove the blank line at run time. Although the time is usually very short, but also is wasting time.
This functionality is naturally supported in Tomcat 6
1. Add the following configuration to the web.xml of the project
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
< trim-directive-whitespaces>true</trim-directive-whitespaces>
</jsp-property-group>
< /jsp-config>
This approach is to remove the blank line when the JSP is compiled into class, so it is a complete and efficient one.
2. Add a piece of code to the header of each JSP
Copy Code code as follows:
<%@ page trimdirectivewhitespaces= "true"%>
The above two methods to take one, we recommend the use of the first.
I hope this article will help you with JSP program design.