【发布时间】:2014-12-19 22:04:01
【问题描述】:
如何更改动态网址的请求映射? URL 可能如下所示:
- http://zz.zz.zz.com:8080/webapp/p1/q9/e3/test?Id=2&maxrows=5
- http://zz.zz.zz.com:8080/webapp/a1/b2/c3/test?Id=2&maxrows=5
- http://zz.zz.zz.com:8080/webapp/x1/y2/z3/test?Id=2&maxrows=5
当 url 采用这种格式时,控制器的工作语法如下:
http://zz.zz.zz.com:8080/webapp/test?Id=2&maxrows=5
@RequestMapping(value = "/test", method = RequestMethod.GET)
public @ResponseBody void test(
@RequestParam(value = "Id", required = true) String Id,
@RequestParam(value = "maxrows", required = true) int maxrows
) throws Exception {
System.out.println("Id: " + Id + " maxrows: " + maxrows);
}
【问题讨论】:
标签: java spring spring-mvc controller