A method of removing blank lines by JSP programming _jsp programming

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.