以下表单提交后,在1.jsp中获取userName的值,最合适的方法是()JavaCWeb
A: Stringname=request.getAttribute("userName");
B: Stringname=request.getParameter("userName");
C: String[]names=request.getParameter("userName");
D: String[]names=request.getParameterValues("userName");
A: Stringname=request.getAttribute("userName");
B: Stringname=request.getParameter("userName");
C: String[]names=request.getParameter("userName");
D: String[]names=request.getParameterValues("userName");
举一反三
- 在login.html中存在如下代码:username:当表单提交时,能够得到文本框的值的是( ) A: request.getAttribute(“userName”) B: request.getParameter(“myName”) C: request. getParameter(“userName”) D: request.getAttribute(“myName”)
- 已知表单有一个参数名为“userName”的参数,提交后,能够正确获得表单对象值的代码是?() A: request.getParameter(“userName”); B: response.getParameter(“userName”); C: request.getParameter(“username”); D: request.getParameterValues(“userName”);
- 通过表单传递参数username,servlet中如何获取参数值() A: request.getParameter(“username”); B: request.getAttribute(“username”); C: session.getAttribute(“username”); D: session.getParameter(“username”);
- 在JSP内置对象中,与请求相关的对象是request对象。该对象可以使用()方法获取表单提交的信息 A: getParameter(Stringname) B: GetParameter(Stringname) C: getAttribute(Stringname) D: GetAttribute(Stringname)
- 中国大学MOOC: 阅读下面代码片段: Servlet1: request.setAttribute(username, 张三);String username=(String) request.getAttribute(username);System.out.println(username:+username);request.setAttribute(username, 李四);username=(String) request.getAttribute(username);System.out.println(username:+username);request.removeAttribute(username);username=(String) request.getAttribute(username);System.out.println(username:+username);当使用浏览器访问Servlet1时控制台会输出什么结果