自定义Jersy Moustache Mvc

问题描述

由于某些原因,Jersey创建的DefaultMustacheFactory实例不适合我的需要,我想像这样创建自己的实例,而不是使用认实例:

DefaultMustacheFactory factory = new DefaultMustacheFactory();
factory.setobjectHandler(new ReflectionObjectHandler() {
  @Override
  protected boolean areMethodsAccessible(Map<?,?> map) {
    return true;
  }
});

如何告诉Jersey创建上述实例?我阅读了球衣(https://eclipse-ee4j.github.io/jersey.github.io/documentation/latest/mvc.html#d0e15510)的文档,找到了属性MustacheMvcFeature.TEMPLATE_OBJECT_FACTORY,但我不知道如何使用它。

背景:Jersey 2.13,Java 11,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

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)