中国大学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时控制台会输出什么结果
举一反三
- 阅读下面代码片段: Servlet1: request.setAttribute("username", "张三"); String username=(String) request.getAttribute("username"); System.out.println("username:"+username); request.setAttribute("username", null); username=(String) request.getAttribute("username"); System.out.println("username:"+username); 当使用浏览器访问Servlet1时控制台会输出什么结果
- 通过表单传递参数username,servlet中如何获取参数值() A: request.getParameter(“username”); B: request.getAttribute(“username”); C: session.getAttribute(“username”); D: session.getParameter(“username”);
- 以下表单提交后,在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");
- 下列选项中,是与$(#username)等价的写法() A: $(username #) B: $(# username ) C: $ (username ) D: jQuery(#username )
- 在login.html中存在如下代码:username:当表单提交时,能够得到文本框的值的是( ) A: request.getAttribute(“userName”) B: request.getParameter(“myName”) C: request. getParameter(“userName”) D: request.getAttribute(“myName”)