【问题标题】:JEditorPane is discarding empty elementsJEdi​​torPane 正在丢弃空元素
【发布时间】:2012-06-02 03:21:05
【问题描述】:

以下测试在 JRE 1.6.0_20 中失败

public void testSetGetTextWithList() throws Exception {
    final JEditorPane editorPane = new JEditorPane();
    editorPane.setContentType("text/html");
    editorPane.setText("<ul><li></li></ul>");
    assertTrue(editorPane.getText().contains("<ul"));
}

当然,空列表和不存在的列表在视觉上是有区别的,所以我希望编辑器丢弃空列表。任何人都可以轻松解决这个问题?

【问题讨论】:

    标签: java html swing html-lists jeditorpane


    【解决方案1】:

    只有当元素是文档中的 last 块元素时才会发生错误,如果将输入更改为其中之一,则测试通过

    <ul><li></li></ul>a
    <ul><li></li></ul><p></p>
    <ul><li></li></ul>&nbsp;
    <ul><li></li></ul><!---->
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-07
      • 2021-10-15
      • 2012-03-14
      • 2011-06-06
      • 2014-06-30
      • 2015-12-17
      相关资源
      最近更新 更多