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

网站开发与客户沟通北京梵客装饰

网站开发与客户沟通,北京梵客装饰,自己的简历网站怎么做,推广产品最好的方式目录 一、引子 二、注解解析 RequestParam 一、要求形参名请求参数名#xff0c;或者是请求实体类时#xff08;已有实体类#xff09;#xff0c;可以不需要加该注解 二、请求参数名!参数名时#xff0c;需要写该注解RequestParam#xff0c;其中 三、一名多值的情…目录 一、引子 二、注解解析 RequestParam 一、要求形参名请求参数名或者是请求实体类时已有实体类可以不需要加该注解 二、请求参数名!参数名时需要写该注解RequestParam其中 三、一名多值的情况使用list时需要用到该注解RequestParam将集合add加入对应数据类型 PathVariable RequestBody RequestHeader 一、引子 最近在写项目时时不时会忘记或者漏写对应的参数注解所以决定简单整理一下相关注解。 二、注解解析 RequestParam 一、要求形参名请求参数名或者是请求实体类时已有实体类可以不需要加该注解 package com.atguigu.param;import com.atguigu.pojo.User; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody;import java.util.List;Controller RequestMapping(param) public class ParamController {RequestMapping(data)ResponseBody//直接接收//要求请求参数名形参名public String data(String name,int age){System.out.println(name name , age age);return name name , age age;}GetMapping(data3)ResponseBody//使用实体对象接值public String data3(User user){System.out.println(user user);return user user;}}二、请求参数名!参数名时需要写该注解RequestParam其中 value“指定请求参数名” requiredfalse前端是否必须传递此参数默认是必须不传报错400 default“1”当非必须传递false可以设默认值 package com.atguigu.param;import com.atguigu.pojo.User; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody;import java.util.List;Controller RequestMapping(param) public class ParamController {GetMapping(data1)ResponseBody//注解指定public String data1(RequestParam(value account) String username,RequestParam(required false,defaultValue 1) int page){System.out.println(username username , page page);return username username , page page;}}三、一名多值的情况使用list时需要用到该注解RequestParam将集合add加入对应数据类型 如果不加该注解将会让hbs对应的一个字符串直接赋值给集合。 package com.atguigu.param;import com.atguigu.pojo.User; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody;import java.util.List;Controller RequestMapping(param) public class ParamController {GetMapping(data2)ResponseBody//特殊值一名多值public String data2(RequestParam ListString hbs){System.out.println(hbs hbs);return hbs hbs;}}PathVariable 路径传参时必须用到PathVariable package com.atguigu.path;import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody;Controller RequestMapping(path) ResponseBody public class PathController {GetMapping({account}/{password})public String login(PathVariable String account,PathVariable String password){System.out.println(account account , password password);return account account , password password;}}RequestBody 前端传入json数据时需要用到RequestBody如PostMappingDeleteMappingPutMapping中有时会用到 package com.atguigu.json;import com.atguigu.pojo.Person; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody;Controller RequestMapping(json) ResponseBody public class JsonController {PostMapping(data)public String data(RequestBody Person person){System.out.println(person person);return person person;}}RequestHeader 用于接收请求头 package com.atguigu.header;import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody;Controller RequestMapping(header) ResponseBody public class HeaderController {RequestMapping (data)public String data(RequestHeader String host){System.out.println(host host);return host host;}}
http://www.w-s-a.com/news/32670/

相关文章:

  • 怎么做自己的个人网站宝安网站设计哪家最好
  • 浩博建设集团网站站长网站统计
  • 电商网站开发视频seo排名优化方式方法
  • 宿迁市住房城乡建设局网站wordpress纯图片主题
  • 广州建设网站 公司湖北省建设信息网官网
  • 网站建立时间查询做百度移动网站优化排
  • 网站建设和运行费用qq恢复官方网站
  • 可以免费建立网站吗免费的网络营销方式
  • 天津企业设计网站建设wordpress标题字体大小
  • 上高县城乡规划建设局网站创业项目
  • 钓鱼网站在线下载广州网站设计哪里好
  • 做阿里国际网站会有成效吗wordpress微博同步
  • 西安网站建设云速网络网站运营情况怎么写
  • 免费建网站的网站微信商城分销系统方案
  • 烟台网站seo服务友情链接有哪些展现形式
  • 什么是移动网站开发免费网站开发框架
  • 做网站 创业wordpress子菜单
  • 门户网站类型有哪些权重7以上的网站
  • 政务网站建设论文android app开发教程
  • 网站开发实训h5总结个人网站注册平台要多少钱
  • 空白网站建设wordpress高亮代码过长
  • 盐城 网站开发什么叫做门户网站
  • 广东快速做网站公司哪家好本地建wordpress
  • dedecms如何做网站贵阳seo计费管理
  • 企业网站设计一般多少钱呼和浩特最好的互联网公司
  • 黄浦专业做网站海南网站策划
  • 网站开发工程师有证书考试吗织梦cms是免费的吗
  • 电子商务网站建设需要学什么门户网站推广介绍方案
  • 网站里的专题页面wordpress查询数据库结构
  • WordPress子站站群网站建设代码生成器