我在JBoss/Spring中做了一個簡單的'get'。我想讓客戶端在URL中傳遞一個整數數組。我如何在服務器上設置它?並顯示客戶端應該發送消息?將數組或列表傳遞給@Pathvariable - Spring/Java
這就是我現在所擁有的。
@RequestMapping(value="/test/{firstNameIds}", method=RequestMethod.GET)
@ResponseBody
public String test(@PathVariable List<Integer> firstNameIds)
{
//What do I do??
return "Dummy";
}
在客戶端,我想通過類似
http://localhost:8080/public/test/[1,3,4,50]
當我這樣做,我得到一個錯誤:
java.lang.IllegalStateException: Could not find @PathVariable [firstNameIds] in @RequestMapping
你可能會需要使用新的Spring 3 UI字段格式http://static.springsource.org/spring/docs/3.0.0.RC1/reference/html/ch05s06.html – 2012-03-08 19:10:56