1.res.json()

var express=require('express');
var app=express(); app.get('/',function(req,res){
//返回json,
res.json({name:'jim',age:'100'});
}) app.listen(9090,function(){
console.log('http://localhost:9090');
})

res.json()将参数转化为json对象,请求方式和res.send差不多

2.res.redirect([status,] path)

重定向到从指定的URL到的另一个URL ,具有指定的statusHTTP状态代码对应的正整数。如果未指定,则status默认为“302”找到“。

res.redirect('/foo/bar');
res.redirect('http://example.com');
res.redirect(301, 'http://example.com');
res.redirect('../login');

重定向可以是用于重定向到其他站点的完全限定URL:

res.redirect('http://google.com');

重定向可以相对于主机名的根目录。例如,如果应用程序已启用http://example.com/admin/post/new,则以下内容将重定向到URL http://example.com/admin

res.redirect('/admin');

重定向可以相对于当前URL。例如,从http://example.com/blog/admin/(注意尾部斜杠),以下将重定向到URL http://example.com/blog/admin/post/new

res.redirect('post/new');

重定向到post/newhttp://example.com/blog/admin(没有尾随斜线),会重定向到http://example.com/blog/post/new

如果您发现上述行为令人困惑,请将路径段视为目录(带有斜杠)和文件,它将开始有意义。

路径相对重定向也是可能的。如果您在 http://example.com/admin/post/new,以下将重定向到 http://example.com/admin/post

res.redirect('..');

一个back重定向请求重定向回引荐,默认为/引荐丢失时。

res.redirect('back');
 

最新文章

  1. [spring源码学习]二、IOC源码——配置文件读取
  2. python基础篇
  3. Pixar Shorts 皮克斯动画短片全集
  4. PHP5的对象复制
  5. 简单JSONP跨域请求
  6. 初识Mongodb之[CURD]-PHP版
  7. XMPP协议的基本理解
  8. [HNOI2002]彩票
  9. 仿照selalchemy实现简单的mongo查询
  10. git 的 origin 的含义
  11. hadoop集群运行jps命令以后Datanode节点未启动的解决办法
  12. Code first 数据迁移
  13. vue cli搭建的vue项目 不小心开了eslint 一直报黄色的警告
  14. matlib实现logistic回归算法(序一)
  15. stm8 时钟输出引脚
  16. springboot+sqlite+maven+mybatis
  17. 临时文件夹迁移 temp位置移动
  18. java对象流与序列化
  19. 20155203 2016-2017-2 《Java程序设计》第1周学习总结
  20. USACO 3.3.1 Riding the Fences 骑马修栅栏(欧拉回路)

热门文章

  1. Bran的内核开发指南_中文版
  2. 美团网 KVM虚拟化公开课学习笔记
  3. iOS APP开发概述----学习笔记001
  4. OpenCV:Visual Studio 2013 Ultimate中OpenCV 2.4.8 配置
  5. 封装RecyclerViewAdapter实现RecyclerView下拉刷新上拉载入很多其它
  6. Extjs grid 设置行字体颜色
  7. Nginx1.6 for centos6.5安装
  8. Spell checker(串)
  9. Android插件化原理解析——Hook机制之动态代理
  10. VmWare 安装 Centos