如何验证HTML符合W3C标准 [英] How to validate that HTML matches W3C standards

查看:390
本文介绍了如何验证HTML符合W3C标准的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 Velocity 模板和Java生成HTML页面的项目。但是大多数页面都不符合 W3C 标准。如何验证这些HTML页面并获取日志告诉我哪些页面上有哪些错误/警告?

I have a project that generates HTML pages using a Velocity template and Java. But most of the pages do not comply with W3C standards. How can I validate those HTML pages and get a log telling me what errors/warnings on what pages?

然后我可以手动修复错误。我尝试过JTidyFilter,但这对我不起作用。

Then I can fix the errors manually. I have tried JTidyFilter, but that doesn't work for me.

推荐答案

经过广泛研究和一点点代码破解后,我我已经设法在我的项目中使用了JTidyFilter,现在它的工作非常好。 JTidyFilter位于JTidyServlet中,这是大约五年前写的JTidy子项目。最近他们更新了代码以符合Java 5编译器。我下载了他们的代码,升级了一些依赖项,最重要的是,改变了处理过滤器的JTidyFilter类中的一些行,最后让它在我的项目中很好地工作。

After extensive research and a little bit code hack, I've managed to use JTidyFilter in my project, and it is working beautifully now. JTidyFilter is in JTidyServlet which is a sub-project of JTidy written about five years ago. Recently they've updated the codes to comply with Java 5 compiler. I downloaded their codes, upgraded some dependencies and most importantly, changed some lines in the JTidyFilter class which handles the filter and finally got it work nicely in my project.

在重新格式化HTML时仍存在一些问题,因为当我使用Firefox HTML验证插件时,我会看到一两个错误,但大多数页面都会通过验证。

There are still some issues in reformatting the HTML, because I can see one or two errors when I use the Firefox HTML validation plugin, but otherwise most pages pass the validation.

这篇关于如何验证HTML符合W3C标准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆