0
Spring MVC的@RequestBody可變整數保護如何保護變量整型數在包裝(容器)WrapperClass到收到一個字符串,而不是一個數?一個字符串
代碼:
@RequestMapping(value = "MyOwnURL", method = RequestMethod.POST)
public @ResponseBody
ResponseSomething createTeam(HttpServletRequest r, @RequestBody WrapperClass wrapperClass) {
//method body
}
class WrapperClass{
Integer number;
//getter and setter
}
當我使用@ModelAttribute註釋soo我可以使用BidindingResult可以捕捉到這個問題。但我不知道如何發送一個具有一個Integer和一個字符串的數組作爲** NO ** JSON數據。 – hard456
發送字符串數組總是 – StanislavL
謝謝。這個解決方案適用於我。但我不確定這是否是最佳解決方案。 – hard456