2016-06-15 1 views
0

У меня есть статический html-файл, к которому я хочу только иметь доступ администратора. Так что я сделать следующее в моей web.xmlПрикладной движок: добавьте ограничение на статический html-файл

<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 СЕРЬЕЗНЫЕ: конфигурация Endpoints не обновляется. Приложение вернуло ошибку, когда сервер Google Cloud Endpoints попытался связаться с ней.

Тогда я пытаюсь изменить каждый .html к .jsp, в том числе фактического статического файла. Когда я это делаю, развертывание работает без ошибок, но когда я пытаюсь получить доступ к своей странице с помощью mydomain/editor.jsp, я могу использовать NOT_FOUND.

ERROR LOG:

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$1.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) 

ответ

0

Файл 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> 
+0

Я хочу поставить ограничение безопасности по умолчанию 'index.html', но он не работает' <индекс веб-ресурса> индекс /index/* http://aaaaaaaaaa.appspot.com/ админ ' –

+0

URL-шаблон не нужен домен. то есть он должен быть «», см. http://stackoverflow.com/questions/15385596/how-are-servlet-url-mappings-in-web-xml-used для получения дополнительной информации. –

Смежные вопросы