客户端使用Form发送数据
在客户端Html文件中Form代码如下:
<!-- POST test -->
<form action="/test" method="post" id="foo" >
<input type="text" name="username">
<input type="password" name="password">
<input type="submit">
</form>
在服务器端处理'/test' POST请求的代码如下:
var bodyParser = require('body-parser');
// ...
// create application/json parser
var jsonParser = bodyParser.json()
// create application/x-www-form-urlencoded parser
var urlencodedParser = bodyParser.urlencoded({ extended: false })
// ...
//
// request from form of the html file
//
app.post('/test', urlencodedParser, function(req, res) {
if (!req.bo