虽然我的嵌入式jetty应用程序在eclipse中运行良好,但它并没有在我的部署中将JSP作为servlet提供。 Jetty不会返回错误,而只是显示我的webapp目录的内容。我可以访问其他servlet,但不能访问在web.xml中设置为我的欢迎文件的console.jsp。
我设置嵌入式服务器和web.xml的代码如下......
Server server;
WebAppContext webappContext = new WebAppContext();
webappContext.setContextPath("/indexers");
webappContext.setWar(IndexerWebApp.class.getResource("/webapp").toExternalForm());
server.setHandler(webappContext);
的web.xml ......
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>Indexer Control Console</display-name>
<welcome-file-list>
<welcome-file>console.jsp</welcome-file>
</welcome-file-list>
<!-- Servlets -->
<servlet>
<servlet-name>launchTask</servlet-name>
<servlet-class>com.hp.it.kmcs.suggest.index.web.servlets.LaunchTask</servlet-class>
</servlet>
<servlet>
<servlet-name>taskStatus</servlet-name>
<servlet-class>com.hp.it.kmcs.suggest.index.web.servlets.GetTaskStatus</servlet-class>
</servlet>
<servlet>
<servlet-name>rescheduleTask</servlet-name>
<servlet-class>com.hp.it.kmcs.suggest.index.web.servlets.RescheduleTask</servlet-class>
</servlet>
<!-- Servlet mappings -->
<servlet-mapping>
<servlet-name>launchTask</servlet-name>
<url-pattern>/launchTask</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>taskStatus</servlet-name>
<url-pattern>/taskStatus</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>rescheduleTask</servlet-name>
<url-pattern>/rescheduleTask</url-pattern>
</servlet-mapping>