1、安装express和body-parser

  npm install express

  npm install body-parser

2‘、案例如下

var express = require('express');
var bodyParser = require('body-parser')
var app = new express(); app.use(bodyParser.urlencoded({extended:false}));
app.use(bodyParser.json()); //引用ejs
app.set('view engine','ejs'); app.get('/',function (req,res) {
res.send("hello express");
}) app.get('/login',function (req,res) {
res.render("login"); }) app.get('/news',function (req,res) {
res.send("hello news1");
}) app.post('/doLogin',function (req,res) {
console.log(req.body);//req.body获取post提交的数据
})
app.listen("");

最新文章

  1. Resolving SQL Server Disk IO bottlenecks
  2. html尖角提示框的实现
  3. 【项目】Http请求在NSMutableURLRequest添加HttpBody的字典params属性
  4. js反射机制
  5. BZOJ3888 [Usaco2015 Jan]Stampede
  6. laravel5.2 移植到新服务器上除了“/”路由 ,其它路由对应的页面显示报404错误(Object not found!)———新装的LAMP没有加载Rewrite模块
  7. tomcat服务器报Server at localhost was unable to start within 45 seconds的问题
  8. Git(Repo)常用命令收集
  9. 关于泛型中<T extends comparable>的理解
  10. #if defined和#if !defined(c语言的宏定义)
  11. 关于自定义jar包(tomcat)的添加
  12. 基于STM32的USB枚举过程学习笔记
  13. R语言︱list用法、批量读取、写出数据时的用法
  14. vue的ajax请求之axios
  15. C#模板设计模式使用和学习心得
  16. Winfrom 动画实现
  17. hd1007
  18. svn钩子
  19. openssl命令实例
  20. 【转】Braid - 一个发人深思的游戏

热门文章

  1. 【异常】org.apache.hadoop.hbase.client.RetriesExhaustedException: Failed after attempts=36, exceptions:
  2. 2019.9.19HTML基础
  3. 一般情况下的NB-IoT网络架构
  4. apache笔记
  5. 设置ecShop网店用户名和email均可登录
  6. java代码中的坑
  7. AT&T 和 Intel
  8. 阿里云-docker安装mysql
  9. hive的外部表
  10. Unity3D资源