Spring MVC正在删除@PathVariable(Spring MVC is dropping a @PathVariable)

编程入门 行业动态 更新时间:2024-10-28 17:14:06
Spring MVC正在删除@PathVariable(Spring MVC is dropping a @PathVariable)

如果我多次敲击控制器并锤击它,偶尔我的modelCode参数将作为null。 但是URL中包含modelCode。 使用Spring Framework 3.0.5.RELEASE

@RequestMapping(value="ws/getallvariants/{channelCode}/{modelCode}/{regionId}/{year}") public ModelAndView getAllVariants(@PathVariable("channelCode") String channelCode, @PathVariable("modelCode") String modelCode,@PathVariable("regionId") String regionId,@PathVariable("year") String year){

if (modelCode == null) { int i = 0; // this should never hit, but does. }

If I hit the controller multiple times and hammer it, occasionally my modelCode parameter comes through as null. However the URL has the modelCode in it. Using Spring Framework 3.0.5.RELEASE

@RequestMapping(value="ws/getallvariants/{channelCode}/{modelCode}/{regionId}/{year}") public ModelAndView getAllVariants(@PathVariable("channelCode") String channelCode, @PathVariable("modelCode") String modelCode,@PathVariable("regionId") String regionId,@PathVariable("year") String 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) {...}

Updating the spring framework again to the latest version appears to have worked. Apparently when we updated our framework something didn't work correctly.

EDIT:

So this wasn't our issue at all... We had implemented a String Trimmer Editor incorrectly and it was keeping state. So when we put the call under load it would cross results.

更多推荐

本文发布于:2023-08-07 23:30:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466054.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:MVC   Spring   dropping   PathVariable

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!