问题
I'm trying to map MyHttpHandler to custom url using grizzly 2.3 web server like this (that should be RESTfull url, like /entity/42/attribute
):
HttpServer httpServer = HttpServer.createSimpleServer();
ServerConfiguration config = httpServer.getServerConfiguration();
config.addHttpHandler(new MyHttpHandler(), "/entity/*/attribute");
It does not work. How can I do it in grizzly?
回答1:
For version 2.3.17 of grizzly-http-server, I see that addHttpHandler(HttpHandler httpHandler, String... mappings) creates HttpHandlerRegistration instances from the mapping Strings:
ServerConfiguration#addHttpHandler (on grepcode.com)
The Javadoc of the fromString method mentions that "*" wildcards are supported:
HttpHandlerRegistration#fromString (on grepcode.com)
来源:https://stackoverflow.com/questions/25309244/wildcards-in-grizzly-httphandlers-mappings