<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!問題解決了!
新聞熱點
疑難解答