4
只需創建我的第一個在tomcat上運行的IntelliJ Web應用程序。在IntelliJ中添加一個servlet,說包javax.servlet.http不存在
該項目運行良好,它使得index.jsp很好。
即使web.xml沒有對btw的引用,index.jsp如何呈現?它是否首先查找心理文件(.jsp's),如果存在,它會執行它們?或者僅僅是servlets的web.xml?
真正的問題是我在/ src文件夾中創建的TestServlet,而且似乎無法找到的javax.servlet罐子:
package javax.servlet.http does not exist
參考:
的web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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"
version="2.5">
<servlet>
<display-name>Test1</display-name>
<servlet-name>TestServlet</servlet-name>
<servlet-class>TestServlet</servlet-class>
</servlet>
</web-app>
TestServlet.java:
import java.io.IOException;
package hello_world.Servlets
/**
* Created by IntelliJ IDEA.
* User: snad
* Date: Oct 29, 2011
* Time: 9:19:27 AM
* To change this template use File | Settings | File Templates.
*/
public class TestServlet extends javax.servlet.http.HttpServlet {
protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {
}
protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {
}
}
我加入到TestServlet.java中:package hello_world.Servlets;在intelliJ中,但web.xml沒有得到更新,應該嗎? – Blankman
我在包中添加了上面的TestServlet.java類,雖然intelliJ已經在其下面放置了一個讀取線。 – Blankman
IntelliJ是否將我的所有外部庫放在構建路徑中?我從哪裏獲得servlet-api.jar? – Blankman