【发布时间】:2016-02-25 10:06:02
【问题描述】:
我已将我的 Servlet 从 2.4 升级到 3.0,并在 Websphere 8.5.5.8 上部署了我的应用程序。应用程序服务器正常启动。
当我尝试在浏览器中访问我的home.jsp 页面时,它会抛出:
控制器主要错误 OG1000SRVE0190E:找不到文件:/servlet/com.platform7.affina.operations.servlet.ValidateLoginUser
当我尝试调试时,代码会碰到我的主控制器 Servlet(它在同一个包中),但在我调用的控制器 servlet 类中:
this.getServletContext().getRequestDispatcher("Servlet/com.platform7.affina.operations.servlet.ValidateLoginUser").forward(request, response);
哪个抛出:
Servlet/com.platform7.affina.operations.servlet.ValidateLoginUser 的 FileNotFoundException。
但ValidateLoginUser 位于同一个包和类文件夹位置!
文件夹结构:
\NEED4SPEEDCell02\operations_1.ear\OperationsWeb.war\WEB-INF\classes\com\platform7\affina\operations\servlet
ControllerMain.class 和 ValidateLoginUser.class 在同一个 servlet 包中。
我的Web.xml 文件:
<servlet>
<servlet-name>servletMain</servlet-name>
<servlet-class>com.platform7.affina.operations.servlet.ControllerMain</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>servletMain</servlet-name>
<url-pattern>/controllerMain</url-pattern>
</servlet-mapping>
所以当我访问我的 URL 时:它点击 ControllerMain.class 但在这个类中我正在调用另一个 servlet,它不是 web.xml 的一部分,但位于 ControllerMain.class 的同一包中。
当我打印真实路径时:this.getServletContext().getRealPath("/"));
我明白了:
C:\WebSphere858\AppServer\profiles\AppSrv01\installedApps\NEED4SPEEDCell02\operations_1.ear\OperationsWeb.war
我也尝试使用getNamedDispatcher(..),但抛出:null。
相同的代码在 Websphere 7 上运行良好,甚至在 Websphere 8.5.5.5 上运行
【问题讨论】:
标签: servlets websphere-8 requestdispatcher