我在Windows 7上的Eclipse Mars上运行Apache Tomcat 8,这是我的代码:
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("/Main")
public class Main extends HttpServlet {
private static final long serialVersionUID = 1L;
public Main() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("");
pw.println("");
pw.println("");
pw.println("<h1>Example 0</h1>");
pw.println("");
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}
启动tomcat,ok,当我访问localhost时可以看到“Example 0”。但是,如果我将响应中的字符串更改为“示例1”,则需要大约10分钟来更改它。我是Servlet / Tomcat开发的初学者,而且我没有理解延迟发生的原因。为什么会这样?
答案 0 :(得分:0)
不是答案,但我建议您使用Netbeans编写Web代码,毫无疑问Eclipse是国王,但Netbeans更好地处理Web内容。