Xpages - 在 Arraylist 中传递 <ahref>

Xpages - Passing <ahref> in Arraylist

我正在尝试将 href 添加到 Arraylist,这很好地添加到 Arraylist,但 link 已损坏。 URL 中问号 (?) 后的所有内容均不包含在 link.

有什么我遗漏的吗,代码如下:

private String processUpdate(Database dbCurrent) throws NotesException {

int intCountSuccessful = 0;
View vwLookup = dbCurrent.getView("DocsDistribution");
ArrayList<String> listArray = new ArrayList<String>();
Document doc = vwLookup.getFirstDocument();

while (doc != null) {
    String paperDistro = doc.getItemValueString("DistroRecords");
    if (paperDistro.equals("")) {
        String ref = doc.getItemValueString("ref");
        String unid = doc.getUniversalID();
        // the link generated when adding to Arraylist is broken
        listArray.add("<a href=\"gandhi.w3schools.com/testbox.nsf/distro.xsp?documentId=\"+ unid + \"&action=openDocument\">" + ref + "</a>");
    }
    Document tmppmDoc = vwLookup.getNextDocument(doc);
    doc.recycle();
    doc = tmppmDoc;
}

Collections.sort(listArray);

String listString = "";
for (String s : listArray) {
    listString += s + ", \t";
}

return listString;

}

您在 " 转义 unid 值时遇到问题,因此您 URL 变为 gandhi.w3schools.com/testbox.nsf/distro.xsp?documentId="+ unid + "&action=openDocument

如果使用String.format()和单引号来生成a标签会更容易阅读:

listArray.add(String.format(
    "<a href='gandhi.w3schools.com/testbox.nsf/distro.xsp?documentId=%s&action=openDocument'>%s</a>", 
    unid, ref));