问答详情
源自:1-3 手工编写第一个Servlet

为什么Post()请求不了点不进去


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()请求....


提问者:weixin_慕仙1176837 2020-10-27 14:33

个回答

  • weixin_慕仙1176837
    2020-10-27 14:54:21

    from

  • weixin_慕仙1176837
    2020-10-27 14:53:48

    找到了,我老是把这个提交表单的form老是写成from?

  • weixin_慕仙1176837
    2020-10-27 14:34:20

    <%@ 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>