自学内容网 自学内容网

【SpringBoot】Web开发之URL映射

@RequestMapping("/getDataById/{id}")

public String getDataById(@PathVariable("id") Long id){

      return "getDataById:"+id;

}46

如果URL中的参数名称与方法中的参数名称一致,则可以简化为:

@RequestMapping("/getDataById/{id}")

public String getDataById(@PathVariable Long id){

  return "getDataById:"+id;

}49

@RequestMapping("/getJson/*.json")

public String getJson(){

     return "get json data";

}52

@RequestMapping(value="/getData",method=RequestMethod.GET)

public String getData(){

     return "RequestMethod GET"; 

}

@RequestMapping(value="/getData",method=RequestMethod.POST)

 public String PostData(){

    return "RequestMethod.POST"

}58


原文地址:https://blog.csdn.net/wenhuakulv2008/article/details/140649041

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!