当前位置: 首页 > news >正文

html框架布局实例代码推广优化网站

html框架布局实例代码,推广优化网站,建设银行储蓄卡申请网站,定制软件系统nest.js控制器: 控制器负责处理传入请求并向客户端返回响应。 为了创建基本控制器,我们使用类和装饰器。装饰器将类与所需的元数据相关联,并使 Nest 能够创建路由映射(将请求绑定到相应的控制器)。 1.获取get请求传参…

nest.js控制器: 控制器负责处理传入请求并向客户端返回响应。
为了创建基本控制器,我们使用类和装饰器。装饰器将类与所需的元数据相关联,并使 Nest 能够创建路由映射(将请求绑定到相应的控制器)。
在这里插入图片描述

1.获取get请求传参,用@Request装饰器或者@Query()装饰器

import {Controller,Get,Request,
} from '@nestjs/common';import { WeiService } from './wei.service';@Controller({path: 'wei',version: '1', //版本控制
})
export class WeiController {constructor(private readonly weiService: WeiService) { }// @Request装饰器@Get()findAll(@Request() req) {console.log('@', req.query)return {code: 200,message: '请求成功W'}}
}
import {Controller,Get,Query,
} from '@nestjs/common';import { WeiService } from './wei.service';@Controller({path: 'wei',version: '1', //版本控制
})
export class WeiController {constructor(private readonly weiService: WeiService) { }// @Query()装饰器@Get()findAll(@Query() query) {console.log('@@', query)return {code: 200,message: '请求Q成功'}}
}

2.post请求获取参数,用@Request装饰器或者@Body 装饰器

import {Controller,Get,Query,
} from '@nestjs/common';import { WeiService } from './wei.service';@Controller({path: 'wei',version: '1',
})
export class WeiController {constructor(private readonly weiService: WeiService) { }//用@Request装饰器@Post()create(@Request() req) {console.log(req.body)return {code: 200,message: '请求成功!'}}
}
import {Controller,Get,Query,
} from '@nestjs/common';import { WeiService } from './wei.service';@Controller({path: 'wei',version: '1',
})
export class WeiController {constructor(private readonly weiService: WeiService) { }//用@Body装饰器@Post()create(@Body() body) {console.log(body)return {code: 200,message: '请求成功!'}}
}

读取请求体中得key值

import {Body,Controller,
} from '@nestjs/common';import { WeiService } from './wei.service';@Controller({path: 'wei',version: '1',
})
export class WeiController {constructor(private readonly weiService: WeiService) { }// 读取key@Post()create(@Body("title") body) {console.log(body)return {code: 200,message: '请求成功'}}
}

动态传参使用 Request装饰器 或者 Param 装饰器

import {Controller,Request,
} from '@nestjs/common';import { WeiService } from './wei.service';@Controller({path: 'wei',version: '1',
})
export class WeiController {constructor(private readonly weiService: WeiService) { }// 动态路由// Request装饰器 或者 Param 装饰器@Get(':id')findId(@Request() req) {console.log('@@@@@@', req.params)return {code: 200,message: '请求成功!!!!!!'}}
}

header信息读取使用@header装饰器

import {Controller,Get,Headers,
} from '@nestjs/common';import { WeiService } from './wei.service';@Controller({path: 'wei',version: '1',
})
export class WeiController {constructor(private readonly weiService: WeiService) { }// 读取header 信息@Get(':id')findId(@Headers() header) {console.log('header', header)return {code: 200,message: '请求成功!!!!!!'}}
}
http://www.hkea.cn/news/965940/

相关文章:

  • 做分类信息网站代码百度搜索推广优化师工作内容
  • 南京网站开发公司关键词推广
  • 合水口网站建设百度指数明星人气榜
  • 上传网站图片处理推广软件免费
  • 做网站怎么写代码下载百度软件
  • 县城做网站网站搭建关键词排名
  • b2b多平台一键发布seo需要掌握哪些技术
  • 网站建设推广合同网络广告联盟
  • 汽车网站正在建设中模板什么是营销模式
  • 宜昌seo百度seo优化
  • 做网站公司q房网seo快速排名站外流量推广
  • 南宁网站排名优化广州发布紧急通知
  • 网站建设的策划方案seo排名
  • 网站模板绑定域名培训班
  • coupang入驻条件2022台州关键词优化报价
  • 网站建设前景怎么样google优化师
  • 上海免费网站建设淘宝引流推广怎么做
  • 单位网站建设目的西安网站建设公司排行榜
  • 福州制作网站软件无人在线观看高清视频单曲直播
  • 建设银行卡网站百度账号登录个人中心
  • 网站显示500错误怎么解决方法seo网站推广排名
  • 广告免费设计在线生成网站排名优化
  • 余姚公司网站建设怎么建网址
  • 网站域名授权怎么做市场营销案例100例
  • kindeditor代码高亮 wordpressseo优化排名经验
  • 家乡介绍网页设计上海网站排名优化
  • 广州黄埔网站制作百度sem是什么意思
  • 网站流量分析网站网络推广营销网
  • 化妆品网站建设计划书网站维护是什么意思
  • 建设局网站公告宣传推广的形式有哪些