我使用在 Ubuntu 12.04 上运行的 Eclipse EE Juno 来测试简单的 servlet。因此,我在 Eclipse 中使用以下命令安装了一个 Web 工具包
sudo apt-get install libwebkitgtk-1.0-0
当我运行 servlet 时,内部浏览器会显示我在 servlet 中使用的 html 标记。像这样(这个问题在 Firefox 中不会发生)
<h3>Hello from servlet!!!</h3>
这是servlet的代码
package org.javaweb;
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;
/**
* Servlet implementation class SimpleServlet
*/
@WebServlet("/SimpleServlet")
public class SimpleServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter printWriter = response.getWriter();
printWriter.println("<h3>Hello from servlet!!!</h3>");
}
}
错误在哪里??如何纠正这个?
谢谢!