一:@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. MySQL分组聚合group_concat + substr_index

    场景:给予一张商品售卖表,表中数据为商品的售卖记录,假设表中数据是定时脚本插入的,每个时间段的商品售卖数量不同,根据此表找各个商品的最多售卖数量的数据. 1.数据表 CREATE TABLE `goo ...

  2. noi.ac#228 book

    分析 代码 #include<bits/stdc++.h> using namespace std; #define int long long const int inf =1e18; ...

  3. mvc中@RenderSection()研究 转载https://www.cnblogs.com/rrxc/p/4062827.html

    一.@RenderSection定义 HelperResult RenderSection(string name) 但是当如果使用了_Layout.cshtml做母版页的页没有实现Section的话 ...

  4. ECMAScript 2015 可迭代协议:迭代普通对象

    可迭代协议允许 JavaScript 对象去定义或定制它们的迭代行为, 例如(定义)在一个 for..of结构中什么值可以被循环(得到). 一些内置类型都是内置的可迭代类型并且有默认的迭代行为( 比如 ...

  5. Git014--Rebase

    Git--Rebase 本文来自于:https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b00 ...

  6. JS中设置input的type="radio"默认选中

    html: <input id="Radio1" type="radio" value="男" name="st_Sex&q ...

  7. golang的数据类型之整型类型

    数据类型: 整数 : int, int32, int64, uint, uint32, uint64 字符串 : string 布尔:bool 浮点:float32 float64 uint 表示无符 ...

  8. spring-第三篇之ApplicationContext的事件机制

    1.通过ApplicationEvent类和ApplicationListener接口,可以实现ApplicationContext的事件处理. 如果容器中有一个ApplicationListener ...

  9. 厉害了,Google大神每天写多少行代码?

    文章转自开源中国社区,编译自:Quora Quora上有个有趣的问题:Google工程师们每天写多少行代码? Google 的 AdMob 全栈工程师 Raymond Farias 在 Quora 发 ...

  10. Python入门习题7.分别统计输入各类字符个数

    例7.用户从键盘输入一行字符,编写一个程序,统计并输出其中的英文字符(包括中文字符).数字.空格和其他字符个数. #字符数统计.py Str = input('请输入一行字符:') alpha = 0 ...