Reputation: 4456
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
Upvotes: 8
Views: 5659
Reputation: 6879
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 );
...
}
Upvotes: 9
Reputation: 9697
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.
Upvotes: 2