0

这是我的简单 form.html :

<form id="login-form" action=" ?? " method="post">Email
    <br/>
    <input type="text" name="Email" id="em" />
    <br/>password
    <br/>
    <input type="text" name="password" id="pas" />
    <br/>
    <br/>
    <br/>
    <input type="submit" value="Submit" />
</form>

这是我的 express node.js 代码 app.js:

app.post('/form', passport.authenticate('local-login', {
    failureFlash: true // allow flash messages
}),

function (req, res) {
    console.log("hello");

    if (req.body.remember) {
        req.session.cookie.maxAge = 1000 * 60 * 3;
    } else {
        req.session.cookie.expires = false;
    }
    res.redirect('/');
});

当我在 action 属性中编写 app.js 路径“our-project/app.js”并提交表单时,没有任何响应。form.html 路径“我们的项目/form/form.html”

4

1 回答 1

0

类似于评论部分中写的内容:

html表单的action部分有点不清楚是什么意思:我会对这个具体的URL路径做action。

例如,如果您想从路径“/path”获取数据,您可以在使用 get 时按字面意思输入它会更改 URL 上的路径,例如:facebook.com/user=id&name=zargold。

或者,如果您希望它 POST 到该特定路径...它将:使用 POST 它将获取该信息...然后我可能会使用 npm 模块 body-parser *因此您可以轻松解析来自正文并提取为 body.name 或 body.email。

于 2015-04-11T15:16:41.013 回答