我正在尝试在自定义 VF 页面上显示指向已上传到“文档”选项卡中的文件夹的 Word 文档的链接。
由于某种原因,这没有按预期工作。该链接未指向该文档。安全也不是问题。我想我在 VF 中做的不对。
这是我的控制器代码:
public with sharing class osv_portal_HomePageContoller {
public string strDocUrl;
public osv_portal_HomePageContoller()
{
    try
    {
        List<Document> lstDocument = [Select Name from Document where Name = 'SLA-Technology' limit 1];
        string strOrgId = UserInfo.getOrganizationId();
        strDocUrl = '/servlet/servlet.FileDownload?file='+lstDocument[0].Id;
    }
    catch (Exception e) 
    {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Error in getDocumentLogoUrl() ' + e.getMessage()));
        System.debug('Error: ' + e.getMessage());
    }
        System.debug('The URL is ' + strDocUrl);
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'The URL returned is ' + strDocUrl));   
    }
}
这是我的 VF 代码:
<apex:outputLink value="{!strDocUrl}" id="theLink" styleclass="slabutton">
    <span class="delete">Service Level Agreement</span>
 </apex:outputLink>
谢谢。