📄 httpservlet.java
字号:
/*源程序清单5-5*/
import java.io.*;
import javax.Servlet.*;
public class HttpServlet extends GenericServlet
{
public void service(ServletRequest req, ServletResponse res)
throws ServletException.IOException
{
//ServletResponse的方法 setContentType设置输出格式
res.setContentType("text/html");
ServletOutputStram out=res.getOutputStream();
out.println("<html>");
out.println("<head><title>Test html page</title></head>");
out.println("<body>");
out.println("<h1>This is a test!</h1>");
out.println("<h2>This is a test again!</h2><br>");
out.println("<a href='http://www.china.com'>China dot com</a>");
out.println("</body>");
out.println("</html>");
}
public String getServletInfo()
{
return "A simple html page!";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -