一:@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模板里面来填充

最新文章

  1. 切换“使用被动式FTP”
  2. TypeError: coercing to Unicode: need string or buffer, ChatRoom found
  3. MATLAB 绘图时的相关心得
  4. hdu 1057 (simulation, use sentinel to avoid boudary testing, use swap trick to avoid extra copy.) 分类: hdoj 2015-06-19 11:58 25人阅读 评论(0) 收藏
  5. 关于mysql的错误 - no query specified
  6. NAT,网络地址转换详解
  7. vb.net之窗体继承
  8. rundeck email配置文件配置
  9. 树状数组(BIT)
  10. 【MSP是什么】MSP认证之项目管理与项目群管理的区别
  11. - 通过 UIBezierPath 做一个中空的扫描器
  12. Android PopupWindow菜单
  13. 项目中ApplicationContext
  14. Shiro中的授权问题(二)
  15. SMB协议原理抓包分析
  16. flink1.7 checkpoint源码分析
  17. SpriteKit 关于categoryBitMask collisionBitMask contactTestBitMask 遇到的一些问题
  18. DJANGO ADMIN 一些有用的设置(转)
  19. Swift3 颜色转换成图片Image
  20. 【线段树】【P4198】 楼房重建

热门文章

  1. PHP 三元运算符?:的小坑
  2. if isinstance(obj, int):
  3. FTP 服务器搭建(基于 CentOS 7)
  4. MySQL 基准测试
  5. EF框架之——Code First以及踩过的这些“坑”
  6. Convolutional Neural Networks(5):Pooling Layer
  7. [eclipse中使用Git插件] 008 - git操作pull、merge、stash、commit
  8. Eclipse常见版本和JDK常用版本对应关系
  9. BZOJ 3262(Treap+树状数组)
  10. Mybatis-技术专区-Mapper接口以及Example的实例函数及详解