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

蒙牛网站是谁做的怎么做网站支付

蒙牛网站是谁做的,怎么做网站支付,网站消耗流量,wordpress修改轮播图前言 SpringMVC#xff08;2#xff09;——controller方法参数与html表单对应#xff08;请求参数的绑定#xff09; 上篇博客我们提到了controller方法的参数与html表单之间的对应关系 但是这种对应关系有很多缺点#xff1a; 传递参数只能放在request的body当中2——controller方法参数与html表单对应请求参数的绑定 上篇博客我们提到了controller方法的参数与html表单之间的对应关系 但是这种对应关系有很多缺点 传递参数只能放在request的body当中url参数无法获取传递参数无法设置哪些不可为空哪些可以为空 SpringMVC为了简化这些繁琐的操作为前后端字段的转换提供了一些很方便的注解 RequestParam注解 Target(ElementType.PARAMETER) Retention(RetentionPolicy.RUNTIME) Documented public interface RequestParam {AliasFor(name)String value() default ;AliasFor(value)String name() default ;boolean required() default true;String defaultValue() default ValueConstants.DEFAULT_NONE;}可以设置是否必传默认值还有对应前端的字段名 value/name属性 作用相同。指定前端form表单传递的参数的名称 required属性 默认true表示必传前端若想调用此controller的此方法必须保证此字段有值 设置为false则表示可以不传 defaultValue属性 表示默认值只有required属性为false时才会生效而且只能指定为字符串类型 demo Controller RequestMapping(/paramAnno) public class ParamAnnoController {RequestMapping(/requestParam)public String requestParamAnno(RequestParam(value name) String username,RequestParam(required false) Integer age,RequestParam(value id) Long id) {System.out.println(RequestParam注解使用生效);System.out.println(name: username ,age: age ,id: id);return suc;}jsp页面的表单部分 h3RequestParam测试/h3form action/paramAnno/requestParam methodpost姓名input typetext namename/br/年龄input typetext nameage/br/idinput typetext nameid/br/input typesubmit value提交/ /formRequestBody注解 Target(ElementType.PARAMETER) Retention(RetentionPolicy.RUNTIME) Documented public interface RequestBody {/*** Whether body content is required.* pDefault is {code true}, leading to an exception thrown in case* there is no body content. Switch this to {code false} if you prefer* {code null} to be passed when the body content is {code null}.* since 3.2*/boolean required() default true;}只有一个required属性表示可传可不传 表示前端传一个js对象给后端js对象中可以包含各种属性 如果想要对应后端的实体类对象需要前端使用js封装为js对象发送给后端form表单做不到发送js对象 我们这里用String代替 PostMapping(value /requestBody)public String requestBodyAnno(RequestBody String body) {System.out.println(RequestBody注解使用生效);System.out.println(body);return suc;}form action/paramAnno/requestBody methodpostf1input typetext namefun.f1/br/f2input typetext namefun.f2/br/f3input typetext namefun.f3/br/list0.f1:input typetext namelist[0].f1/br/list0.f2:input typetext namelist[0].f2/br/list0.f3:input typetext namelist[0].f3/br/list1.f1:input typetext namelist[1].f1/br/list1.f2:input typetext namelist[1].f2/br/list1.f3:input typetext namelist[1].f3/br/birthday:input typetext namebirthday/br/map.f1:input typetext namemap[fun].f1/br/map.f2:input typetext namemap[fun].f2/br/map.f3:input typetext namemap[fun].f3/br/input typesubmit value提交/ /formPathVariable注解 Target(ElementType.PARAMETER) Retention(RetentionPolicy.RUNTIME) Documented public interface PathVariable {/*** Alias for {link #name}.*/AliasFor(name)String value() default ;/*** The name of the path variable to bind to.* since 4.3.3*/AliasFor(value)String name() default ;/*** Whether the path variable is required.* pDefaults to {code true}, leading to an exception being thrown if the path* variable is missing in the incoming request. Switch this to {code false} if* you prefer a {code null} or Java 8 {code java.util.Optional} in this case.* e.g. on a {code ModelAttribute} method which serves for different requests.* since 4.3.3*/boolean required() default true;}属性作用同上这里不再赘述 此注解适用于js基本类型不适用于js对象 作用是直接在请求的url中拼接我们想要的内容比如数字字符串等 需要在RequestMapping中添加{}指定拼接的位置进行使用 PostMapping(/pathVariable/{id})public String pathVariableAnno(PathVariable Long id) {System.out.println(PathVariable注解使用生效);System.out.println(id);return suc;}h3PathVariable测试/h3form action/paramAnno/pathVariable methodpostinput typesubmit value提交/ /formRequestHeader 作用获取指定请求头的值 请求头包含很多属性 PostMapping(value /requestHeader)public String requestHeaderAnno(RequestHeader(value content-type) String contentType,RequestHeader(Accept) String accept) {System.out.println(RequestHeader注解使用生效);System.out.println(contentType);System.out.println(accept);return suc;}h3RequestHeader测试/h3form action/paramAnno/requestHeader methodpostinput typesubmit value提交/ /formCookieValue注解 后端获取前端指定cookie的值 PostMapping(/cookieSession)public String cookieSessionAnno(CookieValue(value JSESSIONID) String cookie) {System.out.println(CookieValue注解使用生效);System.out.println(cookie);return suc;}h3CookieSession测试/h3form action/paramAnno/cookieSession methodpostinput typesubmit value提交/ /formJSESSIONID其实就是session是一种标记http请求状态并且安全的浏览器存储 这里的数据都是经过加密的
http://www.dnsts.com.cn/news/226481.html

相关文章:

  • 网站开发在无形资产中科技图书馆
  • 典型网站开发的流程潍坊网页网站制作
  • 可以做试卷并批改的网站大港油田建设官方网站
  • 科技网站备案网站注销备案查询
  • 怎么建设ftp网站a站是啥
  • 网站制作怎么创业餐饮加盟手机网站建设
  • 常平网站开发网站建设汇报 安全保障
  • WordPress模板资源下载站网站建设平台官网要点有哪些
  • 做公司网站用哪个公司比较好什么软件做网站
  • 如何上传视频到公司网站做网站设计答辩问题
  • 网站开发技术支持与保障企业百度网站建设
  • 杭州网站外包公司合肥论坛
  • 卢松松博客主题 wordpress宁波seo排名优化
  • 做网站公司三年财务预算表南昌成都网站建设方案
  • 做的比较好的返利网站知乎汕头潮南区
  • DW怎么做电商网站广西南宁市住房和城乡建设局网站
  • .mom域名可以做网站吗购物网站 设计
  • 长沙哪里有网站制作触摸屏网站建设
  • 嘉兴网站的优化给网站做h5缓存机制
  • 服务器网站打不开广告门
  • 在dw里如何做网站建筑行业公司
  • 门户网站如何建设方案wordpress最简单模板
  • 电子类 购物网站法拍房北京网站
  • 退役军人事务部网站建设手机制作图片的软件免费
  • 建网站哪个好 优帮云WordPress手机写文章
  • 深圳市土方建设网站高校学生红色网站建设
  • 福州网站设计要多少钱建设手机网站经验分享
  • 网站建设总计手机微信网页版
  • 怎么里ip做网站ppt模板下载完整版
  • asp.net网站连接mysql网站重新搭建程序要多少钱