java定制Jersy胡须Mvc
由于某些原因,Jersey创建的DefaultMustacheFactory
实例不适合我的需要,我希望像这样创建自己的实例,而不是使用默认实例:
DefaultMustacheFactory factory = new DefaultMustacheFactory();
factory.setObjectHandler(new ReflectionObjectHandler() {
@Override
protected boolean areMethodsAccessible(Map<?, ?> map) {
return true;
}
});
我如何告诉Jersey如上所述创建实例?我阅读了jersey(https://eclipse-ee4j.github.io/jersey.github.io/documentation/latest/mvc.html#d0e15510)的文档,找到了属性MustacheMvcFeature.TEMPLATE_OBJECT_FACTORY
,但我不知道如何使用它
背景:Jersey 2.13,Java11,Mustache是Jersey的可传递依赖项
配置:
@ApplicationPath("/api")
public final class OnlineGlossaryApp extends ResourceConfig {
public OnlineGlossaryApp() {
// Jersey features
register(MustacheMvcFeature.class);
property(MustacheMvcFeature.TEMPLATE_BASE_PATH, "/template/");
property(MustacheMvcFeature.TEMPLATE_OBJECT_FACTORY, "should.throw.error");
}
}
目前我不使用web.xml
,但在不久的将来我想我会/必须使用web.xml
共 (0) 个答案