gpt4 book ai didi

java - 应用引擎,JSP "No forced path servlet for/WEB-INF/home.jsp"

转载 作者:搜寻专家 更新时间:2023-11-01 03:07:54 24 4
gpt4 key购买 nike

我有一个 GAE/J 程序(带有 JSP),它可以在开发服务器上完美运行,但是当我将它部署到 App Engine 时,它​​会返回:

Error: Server Error

The server encountered an error and could not complete your request. If the problem persists, please report your problem and mention this error message and the query that caused it.

我使用 Ecplise 来部署我的程序。我的环境和设置:

赢 7 x64

eclipse 版本:Juno Service Release 2构建 ID:20130225-0426

JRE系统库[jdk1.7.0_21]

应用引擎 SDK 1.7.7

在 App Engine 管理控制台日志中显示一个“警告”:

Failed startup of context com.google.apphosting.utils.jetty.RuntimeAppEngineWebAppContext@1c24a0b{/,/base/data/home/apps/s~4562545625ab/1.366972147789894265}
java.lang.IllegalStateException: No forced path servlet for /WEB-INF/home.jsp
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:219)
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:194)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:134)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:438)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:480)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:487)
at com.google.tracing.TraceContext.runInContext(TraceContext.java:774)
at com.google.tracing.TraceContext$DoInTraceContext.runInContext(TraceContext.java:751)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:342)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:334)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:484)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
at java.lang.Thread.run(Thread.java:722)

和一个“关键”:

Uncaught exception from servlet
javax.servlet.UnavailableException: Initialization failed.
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.createHandler(AppVersionHandlerMap.java:228)
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:194)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:134)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:438)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:480)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:487)
at com.google.tracing.TraceContext.runInContext(TraceContext.java:774)
at com.google.tracing.TraceContext$DoInTraceContext.runInContext(TraceContext.java:751)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:342)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:334)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:484)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
at java.lang.Thread.run(Thread.java:722)

web.xml 如下:

    <static-files>
<include path="/stylesheets/main.css" />
</static-files>

<servlet>
<servlet-name>home-jsp</servlet-name>
<jsp-file>/WEB-INF/home.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>home-jsp</servlet-name>
<url-pattern>/WEB-INF/home.jsp</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>Home</servlet-name>
<servlet-class>com.test.HomeServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Home</servlet-name>
<url-pattern>/index/</url-pattern>
</servlet-mapping>

你知道问题出在哪里吗?

最佳答案

/WEB-INF文件夹与 /META-INF 一起文件夹不应公开访问,因为它们可能包含敏感的配置文件和不应单独请求的包含/标记/模板文件。一般的 servletcontainer 对这些文件夹有一个内置的访问限制,这解释了为什么即使您在 web.xml 中显式地重新映射它,您也不能以这种方式访问​​ JSP 页面。 .

如果有问题的 JSP 文件无论如何都应该可以公开访问,那么将它放在 /WEB-INF 中文件夹根本没有意义。只需将 JSP 文件物理移动到该文件夹​​之外,然后删除整个 <servlet><servlet-mapping>条目。这样,您必须能够通过简单地访问 JSP /home.jsp而不是 /WEB-INF/home.jsp .

另一种方法,特别是如果您需要一些预处理业务逻辑,例如从应该在 JSP 中呈现的数据库加载一些数据,将创建一个映射到 URL 模式的 servlet,例如/home并转发到其 doGet() 中的相关 JSP 文件方法。另请参阅 our servlets wiki page 中途某处的第二个 Hello World 示例.

关于java - 应用引擎,JSP "No forced path servlet for/WEB-INF/home.jsp",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16254473/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com