通过 Ninja 框架使用 GAE 时,我似乎无法访问通常位于http:localhost:8080/_ah/admin
. 这是允许您查看数据存储、日志等的控制台。我如何访问它?
问问题
113 次
1 回答
1
因此,我通过查看 ninja-appengine github 自述文件中提供的示例 ninja-appengine 应用程序解决了这个问题。我注意到他们的示例应用程序没有遇到同样的问题,这是由于包含了我丢失的 conf/ServletModule.java 文件。下面的代码做了两件事:
它通过 Java 代码插入 Objectify 过滤器,而不是要求通过 web.xml 包含 objectify 过滤器。
其次,它使 _ah/admin 路径在开发环境中运行时可见。请注意,我刚刚复制了示例 ninja-appengine Web 应用程序中给出的代码:
包配置;
导入 ninja.servlet.NinjaServletDispatcher;
导入 com.google.appengine.api.utils.SystemProperty;导入 com.google.inject.Singleton;导入 com.googlecode.objectify.ObjectifyFilter;
公共类 ServletModule 扩展 com.google.inject.servlet.ServletModule {
@Override
protected void configureServlets() {
bind(NinjaServletDispatcher.class).asEagerSingleton();
// Clean objectify instances with that filter:
bind(ObjectifyFilter.class).in(Singleton.class);
filter("/*").through(ObjectifyFilter.class);
if (SystemProperty.environment.value() == SystemProperty.Environment.Value.Production) {
serve("/*").with(NinjaServletDispatcher.class);
} else {
// do not serve admin stuff like _ah and so on...
// allows to call /_ah/admin and so on
serveRegex("/(?!_ah).*").with(NinjaServletDispatcher.class);
}
}
}
于 2016-08-25T08:42:11.110 回答