You need an HTML Java prefix to clean HTML files at high speed

Web Application I'm working on creating HTML using Velocity templates. The problem is that using spaces in speed patterns and other formatting leads to erroneous HTML (excessive space, misalignment, etc.).

Looking for a good one (packing with one bank would be nice). The HTML Java prefix to run on the generated HTML right before we upload it to the servlet’s response to better understand the source.

Third-party integrators would like to take a look at HTML and find out which patterns are causing problems. The first step to this is good, formatted HTML.

Thank you in advance for any recommendations you can provide!

+5
source share
4 answers

JTidy has a JTidyFilter . Just define it in web.xml and the HTML response will be exaggerated.

+4
source

JTidy may be what you are looking for.

+2
source

There are many HTML parsers here: open source HTML in Java

+1
source

I know that this does not help right now, but I think that the ideal solution would be for Velocity in the first place to support “better whitelisting and management” :).

If many users request and vote for such a feature, perhaps the Velocity team will enable it. Running jTidy or other parsers on the output all the time (for example, for direct requests) consumes a lot of resources, so I'm not sure if this is the best approach, especially for dynamic content, where caching this cleared output does not bring much.

+1
source

All Articles