码迷,mamicode.com
首页 > 其他好文 > 详细

servlet

时间:2018-09-07 17:19:28      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:protect   gen   lap   val   user   opened   open   charset   技术   

1.servlet基本使用方法

获取参数信息:

技术分享图片
@WebServlet("/register")
public class RegisterServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        String username = request.getParameter("username");
        String phone = request.getParameter("username");
        String pwd = request.getParameter("username");
        String[] hobby = request.getParameterValues("hobby");//获取复选框值
        String gender = request.getParameter("gender");
        String course = request.getParameter("course");
        response.getWriter().print("hello");

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    }
}
RegisterServlet.java

 

servlet

标签:protect   gen   lap   val   user   opened   open   charset   技术   

原文地址:https://www.cnblogs.com/zhuxiang1633/p/9605828.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!