首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何解决此警告类型属性(cellpadding)已过时。不鼓励在HTML5文档中使用它

如何解决此警告类型属性(cellpadding)已过时。不鼓励在HTML5文档中使用它
EN

Stack Overflow用户
提问于 2013-01-17 12:49:55
回答 9查看 41.4K关注 0票数 4

我正在使用tapestry开发web应用程序。我正在使用junit测试套件测试我的应用程序,并使用ant build生成war文件和html报告。在我的html报告文件中,我有以下警告。

代码语言:javascript
复制
Multiple annotations found at this line:
    - Attribute (width) is obsolete. Its use is discouraged in HTML5 documents.
    - Attribute (cellpadding) is obsolete. Its use is discouraged in HTML5 
     documents.
    - Undefined attribute value (0). 
    - Attribute (language) is obsolete. Its use is discouraged in HTML5 documents.

以下是我的测试和报告生成代码。

代码语言:javascript
复制
<target name="test" depends="compile" description="Running Test Suite">
        <mkdir dir="${target.data.dir}"/>
        <mkdir dir="${target.htmlreports.dir}"/>
        <junit fork="no" haltonfailure="no" showoutput="yes" printsummary="true" >
        <test name="${junit.class.name}" todir="${target.data.dir}"/>
        <formatter type="brief" usefile="false"/>
        <classpath refid="classpath.test"/>
        <sysproperty key="ant.home" value="${ant.home}"/>   
        <formatter type="xml"/>
        </junit>
        <junitreport todir="${target.htmlreports.dir}">
        <fileset dir="${target.data.dir}">
        <include name="TEST-*.xml"/>
        </fileset>
        <report format="frames" todir="${target.htmlreports.dir}"/>
        </junitreport>
    </target>

这是我的一个html报表文件。

代码语言:javascript
复制
<html xmlns:lxslt="http://xml.apache.org/xslt" xmlns:stringutils="xalan://org.apache.tools.ant.util.StringUtils">
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Unit Test Results: Summary</title>
<link rel="stylesheet" type="text/css" title="Style" href="stylesheet.css">
</head>
<body onload="open('allclasses-frame.html','classListFrame')">
<h1>Unit Test Results.</h1>
<table width="100%">
<tr>
<td align="left"></td><td align="right">Designed for use with <a href="http://www.junit.org/">JUnit</a> and <a href="http://ant.apache.org/">Ant</a>.</td>
</tr>
</table>
<hr size="1">
<h2>Summary</h2>
<table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
<tr valign="top">
<th>Tests</th><th>Failures</th><th>Errors</th><th>Success rate</th><th>Time</th>
</tr>
<tr valign="top" class="Pass">
<td><a title="Display all tests" href="all-tests.html">1</a></td><td><a title="Display all failures" href="alltests-fails.html">0</a></td><td><a title="Display all errors" href="alltests-errors.html">0</a></td><td>100.00%</td><td>0.070</td>
</tr>
</table>
<table border="0" width="95%">
<tr>
<td style="text-align: justify;">
        Note: <em>failures</em> are anticipated and checked for with assertions while <em>errors</em> are unanticipated.
        </td>
</tr>
</table>
<h2>Packages</h2>
<table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
<tr valign="top">
<th width="80%">Name</th><th>Tests</th><th>Errors</th><th>Failures</th><th nowrap>Time(s)</th><th nowrap>Time Stamp</th><th>Host</th>
</tr>
<tr valign="top" class="Pass">
<td><a href="./test/web/app/sampleApp/juint/package-summary.html">test.web.app.sampleApp.juint</a></td><td>1</td><td>0</td><td>0</td><td>0.070</td><td>2013-01-17T04:52:59</td><td>123456</td>
</tr>
</table>
</body>
</html>

请任何人说我怎样才能删除这个警告。

EN

回答 9

Stack Overflow用户

回答已采纳

发布于 2013-01-17 13:40:32

问题出在html报告上,而不是tapestry代码。生成的html报告使用html4属性,这些属性现在已经过时了,比如cellpadding、cellspacing等。这些只是junit测试报告。我不会被他们的html警告所困扰。

票数 1
EN

Stack Overflow用户

发布于 2013-08-08 16:12:37

我面临着同样的问题,我通过使用HTML4.01文档类型而不是HTML5文档类型得到了解决方案。这些警告只是由于HTML5验证器引起的

票数 3
EN

Stack Overflow用户

发布于 2013-01-17 16:59:26

这些警告来自HTML5验证器,很明显,您正在使用的工具在后台运行这样的验证器,并报告一些报告的错误,将它们显示为警告。通过直接在超文本标记语言文档上使用http://validator.nu,还有许多其他的错误消息。

警告“未定义属性值(0)”。然而,这是令人费解的。关于<table border="0">,HTML5验证器这样说可能有点奇怪:“错误:table元素上的border属性值必须为1或为空字符串。要调整表格边框的粗细,请改用CSS。“

检查您使用的工具是否具有用于控制生成的超文本标记语言文档中使用的文档类型(文档类型)的选项(报告的问题是HTML5草案的错误,而不是根据例如XHTML1.0),或者生成的超文本标记语言代码的类型,或者报告问题(例如,“无警告”)。但是,如果可能的话,仅仅禁用警告可能会掩盖真正的问题。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14372380

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档