public class HelloServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out=response.getWriter(); System.out.println("处理Get()请求...."); response.setContentType("text/html;charset=UFT-8"); out.println("<strong>HttpServlet</strong><br/>"); } @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out=response.getWriter(); System.out.println("处理Post()请求...."); response.setContentType("text/html;charset=UFT-8"); out.println("<strong>HttpServlet</strong><br/>"); } }
处理Get()请求...
处理Get()请求....
from
找到了,我老是把这个提交表单的form老是写成from?
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>$Title$</title> </head> <body> <h1>欢迎第一个编写servlet代码</h1> <hr/> <a href="/servlet/HelloServlet"/>Get方式请求HelloServlet</a><br/> <from action="/servlet/HelloServlet" method="dopost"> <input type="submit" value="Post方式请求HelloServlet"/> </from> </body> </html>