zoukankan      html  css  js  c++  java
  • Servlet复习


    public class LoginServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {


    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    req.setCharacterEncoding("utf-8");
    String name = req.getParameter("username");
    String pass = req.getParameter("password");
    String[] hobbys = req.getParameterValues("hobby");
    System.out.println("*************************");
    System.out.println(name);
    System.out.println(pass);
    System.out.println(Arrays.toString(hobbys));
    System.out.println("*************************");
    //通过请求转发
    //req.getRequestDispatcher("/success.jsp").forward(req,resp);
    req.getRequestDispatcher(req.getContextPath()+"/success.jsp").forward(req,resp);
    }
    }

    web映射


    <servlet>
    <servlet-name>LoginServlet</servlet-name>
    <servlet-class>com.kuang.servlet.LoginServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>LoginServlet</servlet-name>
    <url-pattern>/Login</url-pattern>
    </servlet-mapping>
  • 相关阅读:
    docker应用部署
    Netty实现WebSocket通信
    spring-mvc框架简单搭建
    spring-tx 事物
    spring注解及简单实用
    Spring Aop实现简单代码实现
    Jedis操作
    Proxy说明
    下载返回流
    向上捅破天,向下扎到根
  • 原文地址:https://www.cnblogs.com/bellwether/p/14642308.html
Copyright © 2011-2022 走看看