【发布时间】:2016-04-08 14:51:10
【问题描述】:
我创建了一个节点 js 服务器。我正在发送一个包含以下行的 HTML 文件:
<script type="text/javascript" src="jquery.js"></script>
我的应用是这样排列的:
- (目录)服务器:包含“app.js”
- (dir) 脚本:包含“jquery.js”
- (dir) 客户端:包含 html 文件 'index.html'
服务器发送 index.html 文件。 当我按 F12 时,我收到以下错误:
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:8080/jquery.js
我也尝试更改 jquery 文件的目录,但它仍然给我错误。
有什么解决办法吗?谢谢...
【问题讨论】:
-
你能在你提供 HTML 文件的服务器上显示 JS 代码吗?另外,您使用的是
Express吗? -
@Drown 是的,我使用的是 express,服务器代码是:app.get('/screen=:sreenNum', function(request, response) { response.sendFile(path.resolve( '../client/index.html')); });
-
@GuyBen-Shahar — 那么你在哪里定义
/jquery.js的路线? -
@Quentin - 我的服务器在根目录中(我移动了它)。 'jquery.js' 文件和所有其他脚本文件都在 root/scripts 中。我仍然得到 404
-
@GuyBen-Shahar — 我不是在谈论您的 root 目录或目录路径。我说的是您在服务器端 JS 中定义的 路由。
标签: javascript jquery html node.js http-status-code-404