无法find.ejs模板中的href和src属性

当我渲染我的.ejs文件时,href和src属性不引用我的本地文件。 我正在使用node.js和expression。

这是.ejs模板的相关部分。

<head> <title></title> <link rel='stylesheet' href='../public/stylesheets/styles.css' /> <script src="../us-map-1.0.1/lib/raphael.js"></script> <!-- <script src="scale.raphael.js"></script> --> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.js"></script> <script src="../us-map-1.0.1/color.jquery.js"></script> <script src="../us-map-1.0.1/jquery.usmap.js"></script> <script> </head> 

这是呈现模板的路由器

 router.get('/submit', function(req, res, next) {...}); 

这就是典型的查询的样子

HTTP://本地主机:3000 /提交leftHashtag =狗&rightHashtag =猫

任何帮助,为什么发生这将不胜感激。

问题是我没有定义我的静态内容服务。

为了解决这个问题,我在app.js文件中添加了一个app.use语句

 app.use('/submit', express.static(__dirname + '/public')); 

所以,现在任何以/submit开头的路由都将使用该目录在本地的应用程序

 __dirname/public 

使用__dirname作为app.js文件所在的当前目录

如果你想知道更多这个博客更详细地了解正在发生的事情

http://blog.modulus.io/nodejs-and-express-static-content