泽西+吉塞斯不能将非jersey资源与jersey资源混在一起
如何使用非jersey资源和jersey资源搭配guice?
我希望“/”由普通的servlet处理。 但我希望“/ users”由泽西队处理。
假设我有@Path(“/ users”)的泽西资源。 使用以下绑定将无法正常工作,它会尝试使用泽西映射“/”请求,当然这不是泽西资源,我得到404。
protected void configureServlets() { serve("/").with(LoginServlet.class); serve("/*").with(GuiceContainer.class, params); }
我可以找到的所有泽西/ guice的例子就像serve("/rest/*".with(GuiceContainer.class, params);
这对我serve("/rest/*".with(GuiceContainer.class, params);
(“/ rest / users”),但我想要的很好URI没有任何前缀,如’rest’或’ws’。
你与“/”和“/ *”有一个模棱两可的匹配。
要处理此问题,您可以使用允许使用正则表达式而不是简单模式的serve方法的版本。
例如,这样的事情可能有效:
serve("/").with(LoginServlet.class); serveRegex("/.+").with(GuiceContainer.class, params);
现在,GuiceContainer映射在斜杠后至少需要一个字符。