Due to the introduction of package commands and other processing in JSP, the source code of the rendered page contains many line breaks. There are many ways to solve the problem in the past, such as 1. Pay attention to the format in the source code, multiple lines and one line. This compilation is troublesome and the source code is not easy to understand. 2. Write the label by yourself and remove blank lines during runtime. Although the time is generally short, it is also time-consuming. Tomcat 6 naturally supports this feature. 1. Add the following configuration to the project's web. xml:
<Jsp-config> <jsp-property-group> <url-pattern> *. jsp </url-pattern> <trim-directive-whitespaces> true </trim-directive-whitespaces> </jsp-property-group> </jsp-config>
This method removes the blank lines when jsp is compiled into a class. Therefore, it is completed at a time with high efficiency. 2. Add a piece of code <% @ page trimDirectiveWhitespaces = "true" %> to the header of each JSP. You can use either of the above two methods. We recommend that you use the first one.