0
我添加了一個servlet到我的web應用程序和一個servlet映射,但現在只是一個空白屏幕,當我去我的網頁,並且在開發者控制檯中沒有錯誤。誰能幫忙?當我將<servlet-mapping>添加到web.xml時,當我訪問網頁時,歡迎文件不會顯示
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>BasicJavaWeb</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<display-name>AuthenticatorServlet</display-name>
<servlet-name>AuthenticatorServlet</servlet-name>
<servlet-class>AuthenticatorServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AuthenticatorServlet</servlet-name>
<url-pattern>authenticator</url-pattern>
<url-pattern>authenticator</url-pattern>
</servlet-mapping>
</web-app>
之前,我加入的servlet/servlet的映射,這個web.xml文件沒有顯示的index.html:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>BasicJavaWeb</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
所以將這個問題是什麼只需添加的servlet?
檢查您的控制檯開始。你可能有錯誤。而這個錯誤可能是由於你的servlet類在默認包中。永遠不會將任何課程放入默認包中。 –
謝謝!我沒有檢查控制檯,也沒有看到任何錯誤 - 但我使用了默認包並將其移至新包。它仍然沒有工作。 – Tanvi