如果我多次敲击控制器并对其进行锤击,则有时我的modelCode参数会变为null。但是,URL中包含modelCode。
使用Spring Framework 3.0.5.RELEASE
@RequestMapping(value =“ ws / getallvariants / {channelCode} / {modelCode} / {regionId} / {year}”)
公共ModelAndView getAllVariants(@PathVariable(“ channelCode”)字符串channelCode,
@PathVariable(“ modelCode”)字符串modelCode,@ PathVariable(“ regionId”)字符串regionId,@ PathVariable(“ year”)字符串year){ if (modelCode == null) { int i = 0; // this should never hit, but does. }
最佳答案
是的,RegEx对我来说也是最可靠的。这样做是为了获取电子邮件地址作为参数:
@RequestMapping(value = "rest/userreadserv/search/{email:.+}", method = RequestMethod.GET)
public ResponseEntity getUserAccountByEmail(@PathVariable String email) {...}