8

I have the following method in my controller:

@RequestMapping( value="/servers/{server}", method = RequestMethod.GET )
public @ResponseBody List<Application> getServerInformation( String server ) {
    logger.debug( "Request for server: " + server );
    ...
}

When I request /servers/test.myserver.com, the bound variable has value test.myserver. In general, for any request that includes dot-separated values the last part is omitted from the bound variable's value. I am using Spring 3.0.4

Any suggestions?

Thanks

1

2 Answers 2

9

You can use Ant style matching patterns. For your example you can simply do this:

@RequestMapping( value="/servers/{server:.*}", method = RequestMethod.GET )
public @ResponseBody List<Application> getServerInformation(
                          @PathVariable(value = "server") String server ) {
    logger.debug( "Request for server: " + server );
    ...
}
2

You may want to change the useDefaultSuffixPattern of DefaultAnnotationHandlerMapping. Check How to change Spring MVC's behavior in handling url 'dot' character for a discussion on this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.