App Engine:向静态 html 文件添加约束
App engine: add constraint to static html file
我有一个静态 html 文件,我只希望管理员有权访问。所以我在 web.xml
中执行以下操作
<servlet>
<servlet-name>editor</servlet-name>
<jsp-file>/editor.html</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>editor</servlet-name>
<url-pattern>/editor.html</url-pattern>
</servlet-mapping>
<security-constraint>
<web-resource-collection>
<web-resource-name>editor</web-resource-name>
<url-pattern>/editor.html</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
但我总是收到错误。控制台显示
com.google.appengine.tools.admin.AppVersionUpload
checkEndpointsServingStatusResult SEVERE: Endpoints configuration not
updated. The app returned an error when the Google Cloud Endpoints
server attempted to communicate with it.
然后我尝试将每个 .html
更改为 .jsp
,包括实际的静态文件。当我这样做时,部署工作没有错误,但是当我尝试使用 mydomain/editor.jsp
访问我的页面时,我可以 NOT_FOUND
.
错误日志:
java.lang.IllegalStateException: No forced path servlet for /editor.html
at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:679)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.createHandler(AppVersionHandlerMap.java:206)
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:179)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:136)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:469)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:439)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:446)
at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:256)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:310)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:302)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:443)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:235)
at java.lang.Thread.run(Thread.java:745)
jsp文件应该和真实的一样。 (即 /editor.jsp)。您应该可以访问 https://myprojectID.appspot.com/editor
(注意 - 我删除了 .html,但您可以轻松地将其添加回两个 url-pattern
。)
<servlet>
<servlet-name>editor</servlet-name>
<jsp-file>/editor.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>editor</servlet-name>
<url-pattern>/editor</url-pattern>
</servlet-mapping>
<security-constraint>
<web-resource-collection>
<web-resource-name>editor</web-resource-name>
<url-pattern>/editor</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
<user-data-constraint> <!-- Always a good idea to add this -->
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
我有一个静态 html 文件,我只希望管理员有权访问。所以我在 web.xml
<servlet>
<servlet-name>editor</servlet-name>
<jsp-file>/editor.html</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>editor</servlet-name>
<url-pattern>/editor.html</url-pattern>
</servlet-mapping>
<security-constraint>
<web-resource-collection>
<web-resource-name>editor</web-resource-name>
<url-pattern>/editor.html</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
但我总是收到错误。控制台显示
com.google.appengine.tools.admin.AppVersionUpload checkEndpointsServingStatusResult SEVERE: Endpoints configuration not updated. The app returned an error when the Google Cloud Endpoints server attempted to communicate with it.
然后我尝试将每个 .html
更改为 .jsp
,包括实际的静态文件。当我这样做时,部署工作没有错误,但是当我尝试使用 mydomain/editor.jsp
访问我的页面时,我可以 NOT_FOUND
.
错误日志:
java.lang.IllegalStateException: No forced path servlet for /editor.html
at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:679)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.createHandler(AppVersionHandlerMap.java:206)
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:179)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:136)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:469)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:439)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:446)
at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:256)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:310)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:302)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:443)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:235)
at java.lang.Thread.run(Thread.java:745)
jsp文件应该和真实的一样。 (即 /editor.jsp)。您应该可以访问 https://myprojectID.appspot.com/editor
(注意 - 我删除了 .html,但您可以轻松地将其添加回两个 url-pattern
。)
<servlet>
<servlet-name>editor</servlet-name>
<jsp-file>/editor.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>editor</servlet-name>
<url-pattern>/editor</url-pattern>
</servlet-mapping>
<security-constraint>
<web-resource-collection>
<web-resource-name>editor</web-resource-name>
<url-pattern>/editor</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
<user-data-constraint> <!-- Always a good idea to add this -->
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>