Servlet-Helloworld
概述
项目建立:https://www.cnblogs.com/shenleg/p/14251101.html
确保导入Servlet和JSP的包
新建一个Sevlet


新建Servlet
重写doGet、doPost方法,只需要重写一个
⌃O 重写方法

response.setContentType("text/html");
response.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>Hello World!</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Hello World!</h1>");
out.println("</body>");
out.println("</html>");
Web2.3方式
2.3要设置web.xml才能访问

配置映射关系

Web4.0方式
4.0方式使用了注解,更快捷方便,不用设置web.xml

测试



查看类继承关系
要查看的类选中右击


按住Alt 可以放大:

更多功能右击类:

本文来自博客园,作者:神乐g,转载请注明原文链接:https://www.cnblogs.com/shenleg/p/14252142.html

浙公网安备 33010602011771号