Remove blank lines from jsp

Source: Internet
Author: User

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.

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.