Remove the blank line when JSP generates HTML __adobe

Source: Internet
Author: User

Developers using JSP know that the HTML generated by the JSP compiled with a large number of blank lines, these white space generally does not matter, at most, reduce the friendliness of the search engine and HTML readability. However, when using JSP to generate XML files, if the "<?xml" header is not located in the first line of the head, the strict parser will error, like Opera browser.

This problem has plagued me for a long time, plus I have used a lot of taglib, such as jstl tags. Makes my HTML page a big chunk of a bald "white wasteland" that looks awkward. I've been searching the search engine for solutions, but only the questioner, there is no workaround. Today can not help but search a, and finally remove the blank line JSP left a better solution to this problem.

The original Tomcat 5.x added a parameter that specifies whether to remove spaces between the behavior and instructions in the template text. This is the problem of the JSP compiler or only by the compiler itself to solve more thorough.

The Tomcat 5.x version, which is the specification of JSP2.0 and Servlet2.4, is required to include the following bold-character configuration items in the Web.xml configuration.

     <servlet>
         <servlet-name >jsp</servlet-name>
         <servlet-class> Org.apache.jasper.servlet.jspservlet</servlet-class>
         <init-param>
             < Param-name>trimspaces</param-name>
              <param-value>true</param-value>
         </init-param>

         <load-on-startup>3</ Load-on-startup>
     </servlet>

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.