Excluding A URL Pattern From A Wildcard in Spring MVC @RequestMapping

Viewed 154

I have a wildcard Spring MVC mapping that goes something like this:

@RequestMapping(value="**", method={RequestMethod.GET, RequestMethod.POST})
public void doSomething() {

}

However, defined in a Spring @Configuration file, I have this:

public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
   registry.addHandler(pushHandler(), "/websocket").withSockJS();
}

Unfortunately, Spring MVC's wildcard handler ignores the registration of /websocket, meaning my wildcard handler tries to handle my websocket as well.

I tried to change the wildcard pattern so that the @RequestHandler used a negating regex:

@RequestMapping(value="(?!websocket)", method={RequestMethod.GET, RequestMethod.POST}
public void doSomething() {

}

This now excludes the websocket path, but all other paths that I expect the wildcard to pick up now are no longer mapped.

Does anyone have a workable way to exclude a path from a @RequestMapping wildcard? Jason

0 Answers
Related