Home > Article > Web Front-end > How to solve the problem of "cannot post" error when using submit form under Nodejs
<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>
The registration form I wrote was submitted to the registerOK page using a post request. After submission, a "cannot post" error was displayed. The express template engine used, the code is as follows:
app.get("/registOK",function (req,res,next) { res.render("registOK"); });
Later, I searched on the Internet and found that routing generally uses "get", but if you specify "post" for form submission, you must also add one to the routing:
<span style="font-size:18px;">app.post("/registOK",function (req,res,next) { res.render("registOK"); });</span>
ok! The problem is solved!
For more related articles on how to solve the "cannot post" error when using submit to submit a form under Nodejs, please pay attention to the PHP Chinese website!