2013-08-31 104 views
1

我正在通過IntellijIDEA Tomcat集成測試一個Web應用程序(基於Apache Wicket)。在那裏我注意到webapp認爲它運行在tomcat的bin文件夾中。當我調用ServletCotext.getContext(「/」)時,它返回null。但是當我在tomcat中手動部署相同的webapp時,它工作正常。 IntellijIDEA中如何解決這個問題?熱部署tomcat/webapps文件夾表單IntellijIDEA

+1

可能重複的[IntelliJ和Tomcat .. Howto ..?](http://stackoverflow.com/questions/4041356/intellij-and-tomcat-howto) – bummi

回答

0

好的。咱們試試吧。

1)通過WebApplication模板創建IntellijIdea項目。思路應該是最終版本,而不是社區版

enter image description here

2)去跑,編輯configutaion並設置Tomcat的位置文件夾中,這樣的想法會知道你的Tomcat服務器 enter image description here

3)圍棋部署「選項卡並選擇」工件「。應用 enter image description here

4)在src文件夾把你的servlet(你可以試試我測試用的例子) enter image description here

5)進入web.xml文件和鏈接您的Servlet這樣

enter image description here

6)在Web文件夾中把你的.jsp文件(例如hey.jsp)

enter image description here

7)現在你可以通過IntellijIdea啓動你的應用程序。運行(按Shift + F10),並在瀏覽器享受您的應用程序:

- 到JSP文件:http://localhost:8080/hey.jsp(或默認的index.jsp)

- 通過虛擬鏈路的servlet在web.xml中設置:​​