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

xpapad
  • 4,376
  • 1
  • 24
  • 25
  • Duplicate of http://stackoverflow.com/questions/4135329/how-to-change-spring-mvcs-behavior-in-handling-url-dot-character – skaffman Jan 10 '12 at 13:32

2 Answers2

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 );
    ...
}
aweigold
  • 6,532
  • 2
  • 32
  • 46
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.

Community
  • 1
  • 1
Aravind A
  • 9,507
  • 4
  • 36
  • 45