The method for deleting empty lines after JSP compilation is as follows:
1. JSP 2.1 + is supported. The following code is contained in each page to be empty rows:
- <%@ page trimDirectiveWhitespaces="true" %>
The JSP compilation is successfully tested under Tomcat 6.0.14.
2. Support servlet 2.5 +, that is, the XSD version of web. xml is 2.5. Add the following code to web. xml:
- <jsp-config>
- <jsp-property-group>
- <url-pattern>*.jsp</url-pattern>
- <trim-directive-whitespaces>true</trim-directive-whitespaces>
- </jsp-property-group>
- </jsp-config>
The JSP compilation is successfully tested under tomcat 6.0.14.
3. Tomcat 5.5.x +. In the Tomcat installation directory/conf/web. xml, find the servlet named "jsp" and add the following code:
- <init-param>
- <param-name>trimSpaces</param-name>
- <param-value>true</param-value>
- </init-param>
I have never tested it, but the help of the web. xml file in tomcat said so.
TrimSpaces shocould white spaces in template text between actions or directives be trimmed? [False]
In actual operations, I added the 5.5 configuration to the page and started tomcat several times repeatedly, but it was still unsuccessful. Then I thought that JSP has been compiled into servlet, so it could not be changed, go to the work directory in tomcat and delete all the JSP-compiled classes. Wow, the whole world is clean and empty lines are successfully deleted.
- Functions and principles of several encodings in JSP and Servlet
- Introduction to JSP: several solutions to avoid repeated submission of Form forms
- Five Aspects to get started with JSP
- How to Set Up JSP development and running environment
- Introduction to JSP page Jump and request forwarding