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 );
    ...
}
Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.