Home > Web Front-end > JS Tutorial > body text

How to solve the problem of 'cannot post' error when using submit form under Nodejs

高洛峰
Release: 2016-12-06 11:16:16
Original
1331 people have browsed it

<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>
Copy after login

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");
});
Copy after login

Later, I searched on the Internet and found that routing generally uses "get", but if you specify "post" for form submission, you also need to add one to the routing:

<span style="font-size:18px;">app.post("/registOK",function (req,res,next) {
res.render("registOK");
});</span>
Copy after login

ok! The problem is solved!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template