Solve the problem of blank lines in the header of the jsp page

Source: Internet
Author: User
Tags trim

Looking at the blank lines in the header of the jsp page is not very nice. If you want to remove it, remember that the front blank lines are not allowed during wap.

The method is as follows:

First:

The code is as follows: Copy code

<% Out. clear (); %>

Disadvantages the latter part should keep up with the forward indent and not push, mainly because you are still using a blank line for the time being.
Second:

Jsp page command settings:

The code is as follows: Copy code

<% @ Page trimDirectiveWhitespaces = "true" %>

Third:

Or you can configure it in the configuration file web. xml so that this attribute does not need to be set for all pages in the project.

The code is as follows: Copy code

<Jsp-config>
<Jsp-property-group>
<Url-pattern> *. jsp </url-pattern>
<Trim-directive-whitespaces> true </trim-directive-whitespaces>
</Jsp-property-group>
</Jsp-config>


If Tomcat is Tomcat 5.x, that is, the JSP2.0 and Servlet2.4 specifications, add the following to the web. xml configuration:

The code is as follows: Copy code


<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.