时间:2021-07-01 10:21:17 帮助过:7人阅读
- <span style="font-size:18px;"><form action="/registOK" method="get">
- <p>用户名:<input type="text" id="userName" name="userName"></p>
- <p>密码:<input type="password" id="passWord" name="passWord"></p>
- <p><input type="submit" value="注册" id="zhuce"></p></form></span>
我写的注册表单,用post请求提交到registOK页面,提交后提示cannot post错误。用的express模板引擎,代码如下:
- app.get("/registOK",function (req,res,next) {
- res.render("registOK");
- });
后来在网上查找发现,路由一般使用“get”就可以,但如果表单提交你指定了“post”,路由上也得加一条:
- <span style="font-size:18px;">app.post("/registOK",function (req,res,next) {
- res.render("registOK");
- });</span>
ok!问题解决了!