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

前端之家收集整理的这篇文章主要介绍了Nodejs下用submit提交表单提示cannot post错误的解决方法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

介绍了Nodejs下用submit提交表单提示cannot post错误解决方法,非常不错,具有参考借鉴价值,感兴趣的朋友一起看看吧

<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”,路由上也得加一条:

app.post("/registOK",function (req,res,next) { 
res.render("registOK"); 
});


原文链接:https://www.f2er.com/nodejs/44330.html

猜你在找的Node.js相关文章