zoukankan      html  css  js  c++  java
  • 关于前后端分离,post与get后台接收参数注解

     由于spring的RequestParam注解接收的参数是来自于requestHeader中,即请求头,也就是在url中,格式为xxx?username=123&password=456,而RequestBody注解接收的参数则是来自于requestBody中,即请求体中。

    因此综上所述,如果为get请求时,后台接收参数的注解应该为RequestParam,如果为post请求时,则后台接收参数的注解就是为RequestBody。

    两个地址:
    地址① http://localhost:8989/SSSP/emps?pageNo=2
    地址② http://localhost:8989/SSSP/emp/7
    如果想获取地址①中的 pageNo的值 ‘2’ ,则使用  @RequestParam ,
    如果想获取地址②中的 emp/7 中的 ‘7 ’   则使用 @PathVariable

    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public AjaxResult save(@RequestBody Product product) {



    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    public Product get(@PathVariable(value = "id", required = true) Long id)
    • @RequestMapping(value="/emp/{id}",method=RequestMethod.GET)
    • public String edit(@PathVariable("id")Integer id,Map<String , O
       
      • @RequestMapping("/emps")
      • public String list(@RequestParam(value="pageNo",required=false,
    
    
     
    
    
    
  • 相关阅读:
    AttributeError: '_csv.reader' object has no attribute 'next'
    AttributeError: type object '_io.StringIO' has no attribute 'StringIO'
    sklearn学习笔记2
    sklearn学习笔记1
    隐语义模型LFM(latent factor model)
    windows下python3.4安装scikit-learn
    关联规则1
    关联规则
    Jmeter上传文件
    jmeter 学习笔记
  • 原文地址:https://www.cnblogs.com/wgyi140724-/p/10678891.html
Copyright © 2011-2022 走看看