@RequestMapping(value = "/owners/{ownerId}/pets/{petId}", method = RequestMethod.GET) public void findPet(@MatrixVariable Map<String, String> matrixVars, @MatrixVariable(pathVar = "ownerId") Map<String, String> petMatrixVars) { System.out.println(matrixVars); System.out.println(petMatrixVars); }
上面代码是spring文档中的例子,浏览器中输入:http://localhost:8080/owners/44/pets/55;q=22,33;s=23时,控制台输出:
{q=[22, 33], s=[23]} {q=[22, 33], s=[23]}
但是当输入http://localhost:8080/owners/42;q=11;r=12/pets/55;q=22,33;s=23则findPet方法没有执行,难道spring文档有错误?还是少了什么配置?
估计是bug,已提交给springsource,具体分析请看
[url]http://jinnianshilongnian.iteye.com/blog/1872760[/url]
少@PathVariable
public void findPet([b]@PathVariable(value = "ownerId") Integer ownerId , @PathVariable(value = "petId") Integer petId[/b], @MatrixVariable Map matrixVars, @MatrixVariable(pathVar = "ownerId") Map petMatrixVars) {
System.out.println(matrixVars);
System.out.println(petMatrixVars);
}