public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
String username= request.getParameter("username");
request.setAttribute("username", username);//一定要保存,OGNL才能获取${username}

//也可以保存在session中,但是好像视频说不好

//或者直接在jsp页面中用<%=request.getParameter("username")获取,两种结果一样,但是后者有null
request.getRequestDispatcher("/dologin.jsp").forward(request, response);

}

request.setAttribute("username", username);//一定要保存,OGNL才能获取${username}的更多相关文章

  1. request.getAttribute( "result");和request.setAttribute("result",username);

    request.setAttribute("result",username);在request对象中加入名为result的属性并附值为username,因为request对象是可 ...

  2. 如何获得 request, "request.getSession(true).setAttribute("a",a);"与“request.setAttribute("a",a);”区别

    protected ServletContext getServletContext() { return ServletActionContext.getServletContext();} pro ...

  3. request.setAttribute和request.getAttribute还有session.setAttribute和session.getAttribute还有request.getParameter和request.getAttribute区别和联系

    1.session.setAttribute()和session.getAttribute()配对使用,作用域是整个会话期间,在所有的页面都使用这些数据的时候使用. 2.request.setAttr ...

  4. request.getParameter()与request.setAttribute()的区别 (转载)

    request.getParameter()与request.setAttribute()的区别 request.getParameter(),request.setAttribute()区别如下: ...

  5. request.setAttribute()、session.setAttribute()和request.getParameter()的联系与区别(记录)

    1.session.setAttribute()和session.getAttribute()配对使用,作用域是整个会话期间,在所有的页面都使用这些数据的时候使用. 2.request.setAttr ...

  6. request.getSession().setAttribute(&quot;&quot;,..)和request.setAttribute(&quot;&quot;,...)的差别

    request.getSession.setAttribute()是获得当前会话的session,然后再setAttribute到session里面去,有效范围是session而不是request. ...

  7. request.setAttribute()、session.setAttribute()和request.getParameter()的联系与区别

    1.session.setAttribute()和session.getAttribute()配对使用,作用域是整个会话期间,在所有的页面都使用这些数据的时候使用. 2.request.setAttr ...

  8. javaweb: request.getParameter()、request.setAttribute()与request.getAttribute()的作用 (转)

    出处:https://blog.csdn.net/qq_41937388/article/details/87972914 1.request.getParameter()方法是获取通过类似post, ...

  9. request.setAttribute()用法

    小问题: JSP1代码 String [] test=new String[2]; test[0]="1"; test[1]="2"; request.setA ...

随机推荐

  1. 005-shiro认证

    一.shiro认证流程 二.入门程序 1.代码: 2.配置shiro-first.ini 通过此配置文件创建securityManager工厂. 需要修改eclipse的ini的编辑器: 配置数据: ...

  2. django 中模板语言的各种用法

    模板 1.视图中使用模板 模版的创建过程,对于模版,其实就是读取模版(其中嵌套着模版标签),然后将 Model 中获取的数据插入到模版中,最后将信息返回给用户 1.普通方法:HTML被直接硬编码在 P ...

  3. Library Cache优化与SQL游标

    Library Cache主要用于存放SQL游标,而SQL游标最大化共享是Library Cache优化的重要途径,可以使SQL运行开销最低.性能最优. 1 SQL语句与父游标及子游标 在PL/SQL ...

  4. boost shared_ptr weak_ptr

    文档: http://www.boost.org/doc/libs/1_57_0/libs/smart_ptr/shared_ptr.htm shared_ptr构造有个原型 template< ...

  5. for迭代序列的三种方式

    while循环是条件性的,for循环是迭代性的. for循环会访问所有迭代对象中的所有元素,并在所有条目都结束后结束循环. for循环迭代序列有三种基本的方式,分别是通过序列项迭代.通过索引迭代.通过 ...

  6. Linux Shell编程第2章——Linux文件系统

    目录 用户和用户组管理 用户管理常用命令 用户组管理常用命令 文件和目录操作 文件操作常用命令 目录操作常用命令 文件和目录权限管理 文件查找--find 用户和用户组管理 用户管理常用命令 用户的角 ...

  7. 看github上有18万star的第一开源项目如何教你学前端编程的

    作为 Github | star 第一开源项目,已经超过18万 star:比之前最火的bootstrap的10万star还要多出8w,freeCodeCamp 越来越受关注,建站两年时间不到已经近40 ...

  8. springmvc 资源国际化

    <!-- 关于国际化: 1. 在页面上能够根据浏览器语言设置的情况对文本(不是内容), 时间, 数值进行本地化处理 2. 可以在 bean 中获取国际化资源文件 Locale 对应的消息 3. ...

  9. springboot的Scheduled定时器不工作

    问题情况 使用springboot,使用注解方式启动定时器进行业务调度. 在入口类中加了注解如下: package org.test.xyz; @SpringBootApplication @Enab ...

  10. NET中IL指令详解

    名称 说明 Add 将两个值相加并将结果推送到计算堆栈上. Add.Ovf 将两个整数相加,执行溢出检查,并且将结果推送到计算堆栈上. Add.Ovf.Un 将两个无符号整数值相加,执行溢出检查,并且 ...