2017-02-20 79 views
0

我正在使用Wildfly 10並嘗試在其上部署我的Web應用程序。問題在於,如果使用@WebServlet(name = "/testServlet")註釋進行註釋,則不會部署servlet。當我在web.xml中進行servlet映射時(我使用JavaEE 7,因此我想用註釋映射servlet),它仍然被部署。 我的web.xml看起來像Servlet容器未找到servlet(WebServlet註釋不起作用)

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" 
     version="3.1"> 

</web-app> 

,所以我提到了3.1 webapp。我檢查了我的.war archieve中的類,並且存在servlet類。

你能幫我解決這個問題嗎?

回答

0

我發現聲明servlet的錯誤。看起來好像我沒有定義它的url模式。執行此操作的方法是對其進行註釋,如@WebServlet(name = "TestServlet", urlPatterns = "/testServlet")

1

使用名稱和urlpatterns註釋您的servlet。請提供有關此問題的更多詳細信息。 @WebServlet(name =「testing」,urlPatterns = {「/ testing」})