html中<p><input type="text" name='user[name]' placeholder="Username" /></p>在req.body中没有被解析成user.name
发布于 8 年前 作者 insisthzr 4108 次浏览 来自 问答
<html>
	<head>
        <title><%= title %>></title>
        <link rel="stylesheet" href="/stylesheets/style.css" />
    </head>
    <body>
        <% include menu %>
        <h1><%= title %></h1>
        <p>Fill in the form below to sign up!</p>
        <% include messages %>
        <form action="/register" method="post">
            <p><input type="text" name='user[name]' placeholder="Username" /></p>
            <p><input type="password" name='user[pass]' placeholder="Password" /></p>
            <p><input type="submit" value="Sign up" /></p>
        </form>
    </body>
</html>```
```javascript
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser('your secret here.'));
app.use(session());
app.use(messages);
app.use(express.static(path.join(__dirname, 'public')));
app.use(function(req,res,next){
  console.log(req.body);
  next();
});```
为什么req.body.user.name没有被解析
还是req.body.user[name]
回到顶部