一、报错信息
二、原因
三、解决
四、代码
package xiaoxu;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
public class WelcomeServlet extends HttpServlet {
//重写doGet方法
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//1、获取out内置对象
resp.setContentType("text/html;charset=gb2312");
PrintWriter out = resp.getWriter();
out.println("欢迎来到servlet!!!");
}
}