@PathVariable注解
spring mvc中的@PathVariable是用来获得请求url中的动态参数的,十分方便,复习下: 、
- @Controller
- public class TestController {
- @RequestMapping(value="/user/{userId}/roles/{roleId}",method = RequestMethod.GET)
- public String getLogin(@PathVariable("userId") String userId,
- @PathVariable("roleId") String roleId){
- System.out.println("User Id : " + userId);
- System.out.println("Role Id : " + roleId);
- return "hello";
- }
- @RequestMapping(value="/product/{productId}",method = RequestMethod.GET)
- public String getProduct(@PathVariable("productId") String productId){
- System.out.println("Product Id : " + productId);
- return "hello";
- }
- @RequestMapping(value="/javabeat/{regexp1:[a-z-]+}",
- method = RequestMethod.GET)
- public String getRegExp(@PathVariable("regexp1") String regexp1){
- System.out.println("URI Part 1 : " + regexp1);
- return "hello";
- }
- }
http://jackyrong.iteye.com/blog/2059307 感谢分享,学习了!~
@PathVariable注解的更多相关文章
- @pathvariable 注解
1.4. @PathVariable 注解 带占位符的 URL 是 Spring3.0 新增的功能,该功能在SpringMVC 向 REST 目标挺进发展过程中具有里程碑的意义 通过 @PathVar ...
- REST风格,@PathVariable注解
REST(Representational State Transfer,表述性状态转移)是一种软件风格.所谓的REST风格可以简单理解为:使用url表示资源时,每个资源都用一个独一无二的url来表示 ...
- @RequestMapping 和@ResponseBody 和 @RequestBody和@PathVariable 注解 注解用法
接下来讲解一下 @RequestMapping 和@ResponseBody 和 @RequestBody和@PathVariable 注解 注解用法 @RequestMapping 为url映射路 ...
- 【SpringMVC】---RequestMapping、Ant 路径、PathVariable 注解、HiddenHttpMethodFilter 过滤器、用 POJO 作为参数
一.web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi=&qu ...
- @PathVariable注解的使用和@Requestparam
一. @PathVariable @PathVariable这是一个路径映射格式的书写方式注解,在类映射路径的后加上/{对应方法参数中属性@PathVariable("code") ...
- @RequestParam,@RequestBody,@ResponseBody,@PathVariable注解的一点小总结
一.前提知识: http协议规定一次请求对应一次响应,根据不同的请求方式,请求的内容会有所不同: 发送GET请求是没有请求体的,参数会直接拼接保留到url后一并发送: 而POST请求是带有请求体的,带 ...
- @RequestParam,@RequestBody,@PathVariable注解还分不清吗?
前言 在使用 SpringMVC 开发时,经常遇到前端传递的各种参数,比如 form 表单,JSON 数据,String[] 数组,再或者是最常见的 String 字符串等等,总之大部分场景都是在标题 ...
- Spring MVC @PathVariable注解
下面用代码来演示@PathVariable传参方式 @RequestMapping("/user/{id}") public String test(@PathVariable(& ...
- @PathVariable注解的使用
带占位符的 URL 是 Spring3.0 新增的功能,该功能在SpringMVC 向 REST 目标挺进发展过程中具有里程碑的意义. 通过 @PathVariable 可以将 URL 中占位符参数绑 ...
随机推荐
- Jetty 简单使用
Jetty与Tomcat类似,也是一种Servlet引擎,可以用来运行Java Web项目. 其常被嵌入到项目中,以便于开发.测试,以及Demo等项目的运行. 1.作为插件——作为开发.测试时项目运行 ...
- js随机从数组中取出几个元素
JS如何从一个数组中随机取出一个元素或者几个元素. 假如数组为 var items = ['1','2','4','5','6','7','8','9','10']; 1.从数组items中随机取出一 ...
- [Mongodb]删除指定字段
摘要 如果想要删除mongodb中一个document的某个字段,该如何做呢? 方法模版 db.user.update({"email_state":{"$exists& ...
- [译]AngularJS Service vs Factory - Once and for all
原文: http://blog.thoughtram.io/angular/2015/07/07/service-vs-factory-once-and-for-all.html Service和Fa ...
- Error: [ng:areq] Argument 'xxxx' is not a function, got undefined
"Error: [ng:areq] Argument 'keywords' is not a function, got undefined" 代码类似这样的: <div n ...
- 解决英文或数字在HTMl网页中不自动换行。
对于网页设计的新手而言,在接触一段时间的HTML/CSS后,一定会遇到这样的问题:对于已经定义了宽度的容器(如DIV,TD,段落等)如果里面出现了较长的英文或数字,则内容不能自动换行然后会将框架撑出设 ...
- javascript 2048游戏
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 安装cocopods
http://www.tuicool.com/articles/7VvuAr3 OS 最新版 CocoaPods 的安装流程 1.移除现有Ruby默认源 $gem sources --remove h ...
- Swift编程语言资料合集
在本周二凌晨召开的苹果年度开发者大会WWDC上,苹果公司推出了全新的编程语言Swift.Swift 基于C和Objective-C,是供iOS和OS X应用编程的全新语言,更加高效.现代.安全,可以提 ...
- 统计学 nested_design 嵌套设计
nested_design 嵌套设计 li_volleyball ,邓邦良 2016年3月6日 嵌套设计 一.基本概念 嵌套设计(nested design)又称为窝设计和套设计,与析因设计的处理不同 ...