Nodejs下用submit提交表单提示cannot post错误的解决方法

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

Nodejs下用submit提交表单提示cannot post错误的解决方法

xiongtm   2020-05-15 我要评论
<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!问题解决了!

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们