2019-05-14

小结
1.获取页面参数的方法
Username 指的是input里面的name值
request.getParameter(“username”);
        String u_name=request.getParameter("username");
        String p_w=request.getParameter("password");
        System.out.println("账号"+u_name+";"+"密码"+p_w);
2.跳转页面  
request.getRequestDispatcher(“url”).forword(request,response);
Response.sedRedirect(“url”);
            跳转到登录界面
            request.getRequestDispatcher("t1.html").forward(request, response);
            重定
            response.sendRedirect("t1.html");
3.页面之间相互参数(域对象)
A            “aaa”
“c”                new Car();
(1)设置  。SetAttribute(key-string ,value-Object)
Request.setAttribute
<%  
pageContext.setAttribute("page", "page");
    request.setAttribute("request", "requset");
    session.setAttribute("session", "session");
    application.setAttribute("application", "application");
%>


(2)获取   servelt        
    String s=(String)request.getAttribute("request");
    String s1=(String)request.getSession().getAttribute("session");
    String s2=(String)request.getServletContext().getAttribute("application");
    System.out.println(s+";"+s1+";"+s2);  

String x=(String)Request.getAttribute(“A”);
Car c=(Car)request.getAttribute();
a.Jsp
<%=request/session/application.getAttribute(“dsf”)>

你可能感兴趣的:(2019-05-14)