javascript - 无法加载资源: the server responded with a status of 404 (Not Found)

标签 javascript servlets extjs

我尝试加载 grid(xml) 的 servlet,但收到错误“加载资源失败:服务器响应服务器中的状态为 404(未找到)错误”。我该如何解决这个问题?

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Data Binding Example</title>
<!-- <script type="text/javascript" src="ext-5.1.1/ext-all.js"></script> -->

<script type="text/javascript" src="ext-5.1.1/build/ext-all-debug.js"></script>

<link rel="stylesheet" type="text/css"
    href="ext-5.1.1/examples/shared/example.css" />

<!-- GC -->

<script type="text/javascript"
    src="ext-5.1.1/examples/shared/include-ext.js"></script>
<script type="text/javascript"
    src="ext-5.1.1/examples/shared/options-toolbar.js"></script>

<!-- page specific -->
<script type="text/javascript" src="app.js"></script>
</head>
<body>
    <h1>Data Binding Example</h1>
<!--    <p> -->
<!--        This example expands upon the <a href="xml-grid.html">XML Grid -->
<!--            example</a> and shows how to implement data binding for a master-detail -->
<!--        view. -->
<!--    </p> -->
<!--    <p> -->
<!--        Note that the js is not minified so it is readable. See <a -->
<!--            href="app.js">app.js</a>. -->
<!--    </p> -->
    <div id="binding-example"></div>
</body>
</html>

最佳答案

还要确保您的链接正确,尝试使用绝对路径:

"<a href="/HomeDirectory/Data/Xml/xml-grid.html">"

如果这不起作用,请提供更多信息。

如果您没有任何服务器端代码,则很难从您的目录加载 XML 文件。

如果内容非常简单(例如只是一个列表),那么您的文件可能只是一个简单的数组。

var questions = [
  "What time is it?",
  "Is the sky blue?",
  "What do you call a fish with no legs?"
];

您可以使用脚本标记将此文件包含在您的页面中:

<script src="questions.js"></script>

如果您的问题结构更复杂,您可以将其包含在允许复杂嵌套等的 JSON 格式中。

var questions = [
  {
    "id":1,
    "question":"What time is it?",
    "datatype":"text"
  },
  {
    "id":2,
    "question":"Is the sky blue?",
    "datatype":"boolean"
  },
  {
    "id":3,
    "question":"What do you call a fish with no legs?",
    "datatype":"text"
  }
];

关于javascript - 无法加载资源: the server responded with a status of 404 (Not Found),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32005244/

相关文章:

javascript - 如何在 Angular 中制作单选按钮

javascript - 使用 Mootools、jQuery 或 Ajax 查找城市和州的 ASP.NET Javascript 邮政编码

JSP作为 View 技术?

java - 如何在 liferay 中创建顶级 servlet

javascript - Extjs 4 如何在没有 doComponentLayout 的情况下隐藏/显示组合框字段上的触发器?

javascript - 日期比较在某些浏览器中不起作用 - Javascript

javascript - &lt;input type ="time"step ="1"> 在 Chromium 的 .value 中不返回秒数

CSS 无法在 jsp、tomcat 和 servlet 中正确加载

javascript - 在 ExtJS/Javascript 中处理事件的更好方法

extjs - 扩展的 ExtJS 类找不到自定义监听器函数 - "oe is undefined"