【问题标题】:Images from outside wwwroot not displaying (despite mapping)来自 wwwroot 外部的图像未显示(尽管有映射)
【发布时间】:2012-11-16 17:47:15
【问题描述】:

在我的 ColdFusion 应用程序中,我想将 wwwroot 之外的图像保存在以下文件夹中:C:\extSite\stdImages

我在 wwwroot\WEB-INF\jrun-web.xml 中创建了一个映射,如下所示:

<virtual-mapping>
    <resource-path>/extStdImages</resource-path>
    <system-path>C:\extSite\stdImages\</system-path>
</virtual-mapping>

要显示图像,我这样做:

<img src="/extStdImages/abc.jpg">

这在我的开发站点(使用 ColdFusion 的内置 Web 服务器)上运行良好,但图像不会在生产中显示(我使用 IIS)。我想知道是否必须在 IIS 或生产服务器上的其他地方进行一些调整以允许访问这些文件。

有人可以帮忙吗?提前致谢!

彼得

【问题讨论】:

    标签: iis coldfusion


    【解决方案1】:

    在 iis 中,您需要创建一个指向图像文件夹的虚拟目录。尽管将图像放在 wwwroot 之外是没有意义的,因为它们必须可以通过网络访问才能显示在网页上。这样做的唯一原因是。如果您使用密码保护版权图像而不是直接链接到它们。

    【讨论】:

      【解决方案2】:

      如果你在 IIS 上,你可能想为你的 web.config 查看这个

      http://www.iis.net/configreference/system.applicationhost/sites/site/application/virtualdirectory

      这是一个示例:

      <site name="Contoso" id="2" serverAutoStart="true">
         <application path="/">
            <virtualDirectory path="/" physicalPath="C:\Contoso\Content" />
         </application>
         <application path="/CRM">
            <virtualDirectory path="/" physicalPath="C:\Contoso\Content\CRM" />
            <virtualDirectory path="/Images" physicalPath="E:\Images" />
         </application>
         <bindings>
            <binding protocol="http" bindingInformation="*:80:www.contoso.com" />
         </bindings>
      </site>
      

      【讨论】:

        【解决方案3】:

        这是错误的 C:\extSite\stdImages\ 您必须对 CF 使用斜杠而不是反斜杠 这是正确的并且有效 C:/extSite/stdImages/

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2012-09-18
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2021-09-05
          • 2021-05-20
          • 1970-01-01
          相关资源
          最近更新 更多