一:@RequestParam

@RequestParam是传递参数的.

@RequestParam用于将请求参数区数据映射到功能处理方法的参数上。

public Object Login(@RequestParam(value = "name",defaultValue = "lisi") String name, @RequestParam("password")String password)

在URL中发送请求:http://localhost:8080/welcome?name=lisi&&password=1234

defaultValue是默认值。现在是默认为"lisi"。如果请求的name=zhangsan。是以实际的请求为准的。
二:@PathVariable

@PathVariable绑定URI模板变量值

@RequestMapping(value="/users/{userId}/topics/{topicId}")
public String test( @PathVariable(value="userId") int userId, @PathVariable(value="topicId") int topicId)

如请求的URL为“控制器URL/users/123/topics/456”,则自动将URL中模板变量{userId}和{topicId}绑定到通过@PathVariable注解的同名参数上,即入参后userId=123、topicId=456。代码在PathVariableTypeController中

1):

@RequestParam是自己写给URL的。作为参数。

@PathVariable是从URL中取到的值。作为Controller中入参。

2):

@RequestParam 是从request里面拿取值,

@PathVariable 是从一个URI模板里面来填充

@RequestParam和@PathVariable的区别的更多相关文章

  1. @RequestParam 和 @ PathVariable 的区别

    @RequestParam 和 @ PathVariable 的区别http://localhost:8080/Springmvc/user/page.do?pageSize=3&pageNo ...

  2. @RequestParam和@PathVariable的区别及其应用场景

    @RequestParam和@PathVariable这两者之间区别不大,主要是请求的URL不一样 用@RequestParam请求接口时,URL是:http://www.test.com/user/ ...

  3. @RequestParam与@PathVariable的区别

    在spring MVC中,两者的作用都是将request里的参数的值绑定到contorl里的方法参数里的,区别在于,URL写法不同. 使用@RequestParam时,URL是这样的:http://h ...

  4. springMVC的注解@RequestParam与@PathVariable的区别

    1.在SpringMVC后台控制层获取参数的方式主要有两种, 一种是request.getParameter("name"),另外一种是用注解@RequestParam直接获取. ...

  5. springMVC中的注解@RequestParam与@PathVariable的区别

    1.@PathVariable @PathVariable绑定URI模板变量值 @PathVariable是用来获得请求url中的动态参数的 @PathVariable用于将请求URL中的模板变量映射 ...

  6. SpringMVC 中的注解@RequestParam与@PathVariable的区别

    @PathVariable绑定URI模板变量值 @PathVariable是用来获得请求url中的动态参数的 @PathVariable用于将请求URL中的模板变量映射到功能处理方法的参数上.//配置 ...

  7. @RequestParam,@PathVariable等注解区别

    一.@RequestParam和@PathVariable的区别 1.@RequestParam是从uri中request后面的参数串来取得参数的 2.@PathVariable是从uri模板中取得参 ...

  8. 浅谈 @RequestParam 和@PathVariable

    版权声明:本文为博主原创文章,如果对你有用,敬请带走! https://blog.csdn.net/chuck_kui/article/details/55506723 首先 上两个地址: 地址①ht ...

  9. 【转】@RequestParam @RequestBody @PathVariable 等参数绑定注解详解

    @RequestParam @RequestBody @PathVariable 等参数绑定注解详解 2014-06-02 11:24 23683人阅读 评论(2) 收藏 举报 目录(?)[+] 引言 ...

随机推荐

  1. pandas 增删改查

    原文链接:https://blog.csdn.net/zhangchuang601/article/details/79583551 准备工作:增.删.改.查的方法有很多很多种,这里只展示出常用的几种 ...

  2. 【OpenGL】---认识CubeTexture

    一.OpenGL Cube Texture 立方体纹理 立方体纹理是一种特殊的纹理技术,他用6幅二维贴图构成一个以原点为中心的纹理立方体.对于每个片段,纹理坐标(s,t,r)被当做三维向量看待,每个纹 ...

  3. 有趣的linux指令

    1.cmatrix sudo apt-get update sudo apt-get install cmatrix 2.asciiquarium wget http://search.cpan.or ...

  4. 07 (H5*) js课程第8天 高阶函数、闭包、沙箱

    目录: 1:call和apply方法调用 2:bind方法复制 3:函数中的几个属性值 4:高阶函数,函数作为参数 5:高阶函数,函数作为返回值. 6:   作用域链,作用域,预解析 7:闭包--延长 ...

  5. vsphere虚拟化之 NTP服务的创建(三)

    1.先修改windows 2012的注册表. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config\ 设置 Annou ...

  6. Throwable -抛出异常类与自定义异常类

    /* 自定义异常类 java提供的异常类,不够我们使用,需要自己定义一些异常类 格式: public class XXXException extends Exception/runtimeExcep ...

  7. [Linux] 023 RPM 包校验与文件提取

    1. RPM 包校验 $ rpm -V 已安装的包名 选项 释义 -V (verify) 校验指定 RPM 包中的文件 (1) 验证内容中的 8 个信息的具体内容如下 信息名称 释义 S 文件大小是否 ...

  8. hdu3664 Permutation Counting(dp)

    hdu3664 Permutation Counting 题目传送门 题意: 在一个序列中,如果有k个数满足a[i]>i:那么这个序列的E值为k,问你 在n的全排列中,有多少个排列是恰好是E值为 ...

  9. C# 引用类型的深度拷贝帮助类

    using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Lin ...

  10. ansiable介绍及安装

    ansible介绍: Ansible默认通过 SSH 协议管理机器. ssh协议介绍:https://www.cnblogs.com/yaozhiqiang/p/9944894.html 安装ansi ...