3

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.
    }

Dilbert789
  • 864
  • 2
  • 14
  • 29

4 Answers4

3

Yes, RegEx was the most reliable for me as well. Did this to grab an email address as a parameter:

@RequestMapping(value = "rest/userreadserv/search/{email:.+}", method = RequestMethod.GET)
public ResponseEntity getUserAccountByEmail(@PathVariable String email) {...}
Todd
  • 31
  • 2
1

Take a look at Spring MVC @PathVariable getting truncated . The regex approach worked for me:

@RequestMapping({ "/servers/{serverName:.+}" })

Community
  • 1
  • 1
Ted Pennings
  • 1,039
  • 1
  • 14
  • 15
  • 1
    In this case not the issue. The parameter is 2 or three alpha numeric characters, no decimals. I've also seen the regionId now go null. – Dilbert789 Apr 13 '11 at 16:38
0
//in your xml dispatcher  add this property to your default annotation mapper bean as follow
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping">
    <property name="alwaysUseFullPath" value="true"></property>
</bean>       
Fareed Alnamrouti
  • 30,771
  • 4
  • 85
  • 76
0

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.

Dilbert789
  • 864
  • 2
  • 14
  • 29