Web jsp开发学习——前端后台传参方法

一、前端传后台:

1.1表单数据的传递

 

前端的表单里定义名字name

 

后台通过名字获取输入的值

 

 

 

 

1.2页面点击了哪个按钮传递

登录注销的另一种方式

 

点击登录的地方设置参数

 

点击注销的地方设置参数

 

 

在servlet里判断

二、后台传前台:

request/session/application/……

后台放东西

 

    protected void login(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
        RequestDispatcher rd = request.getRequestDispatcher("failure.jsp");
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        String msg = "用户名或密码不符合要求!";
        request.setAttribute("server_info_login", msg);
        rd.forward(request, response);
    } 

前台拿东西

 

猜你喜欢

转载自www.cnblogs.com/caiyishuai/p/10688864.html