1. 写一个 Servlet 类
public class MyServlet extends HttpServlet{
//继承 HttpServlet
//重写 service 方法
//常规导包
@Override
protected void service(HttpServletRequest
arg0, HttpServletResponse arg1p) throws
ServletException, IOException {
System.out.println("My First Servlet");
//处理请求乱码
arg0.setCharacterEncoding("utf-8");
//处理响应乱码
arg1p.setContentType("text/html;charset=utf-
8");
//输出打印
PrintWriter wr = arg1p.getWriter();
wr.print("welcome MyServlet"+"啦啦啦啦啦");
wr.close();
}
}
评论0
最新资源