2
我試圖在war文件中創建一個簡單的servlet並將其部署到所有配置中的jboss 6。我的問題是,我得到一個測試jsp文件來處理url「localhost:8080/workbox /」,但我無法在「localhost:8080/workbox/TestServlet /」中調用servlet。該servlet返回一個「404不可用」。任何幫助,將不勝感激:jboss url form servlet
Servlet的源代碼:編譯.war文件
package se.marthin.web;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/TestServlet")
public class TestServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException, IOException {
resp.setContentType("text/html");
PrintWriter writer = resp.getWriter();
writer.println("<h1> asdasdadsadsasddas" +
"</h1>");
writer.close();
}
}
包裝結構:
META-INF/
MANIFEST.MF
WEB-INF/
web.xml
classes/
se/marthin/web/TestServlet.class
lib/
index.jsp
源代碼的web.xml:
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
你在web.xml中有什麼? –
添加了源代碼 – Marthin
你可以嘗試在你的web.xml中聲明servlet嗎?可能註釋被容器忽略。 –