【发布时间】:2017-12-08 13:51:04
【问题描述】:
我有 View 我需要从 db 获取 pic 的 src 值。
这里是查看代码
<tbody id="findings" style="overflow-y: scroll;">
@foreach (var item in Model)
{
<tr>
<td class="point">
@(rowNo += 1)
</td>
<td style="display:none" id="patientId" class="title">
@Html.DisplayFor(modelItem => item.Patient_id)
</td>
<td class="title">
@Html.DisplayFor(modelItem => item.Patient.Date_of_Birthday)
</td>
<td id="nameVal" class="title">
@Html.DisplayFor(modelItem => item.Patient.Name)
</td>
<td class="title">
@Html.DisplayFor(modelItem => item.Start_appointment)
</td>
<td class="title">
<img src="@item.Calculation.CalculationStatus" />
</td>
<td class="title"></td>
<td class="title"></td>
</tr>
}
</tbody>
但是当我运行时出现错误
加载资源失败:服务器响应状态为 404 (未找到)
在页面源中我有这个<td class="title">
<img src="~/images/status_icons/openedCalculation.png" />
</td>
我不明白为什么页面没有显示。
【问题讨论】:
-
你能告诉我们你在哪里找到那个文件吗?给定路径,images 文件夹应该位于您的 Web 项目的根目录下。
-
为了测试目的,输入资源图像文件的完整绝对路径。
-
您是否检查过该文件是否确实存在? 404 表示在指定位置找不到资源(页面/图像/...)。
-
是的。图片位于 project@hbulens 的根目录中
-
是的,因为这是纯 html,而不是服务器端标记。没有什么可以取代
~符号。试试<img src="@Url.Content("~/images/status_icons/openedCalculation.png")" />
标签: html asp.net asp.net-mvc