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. QT Creator常用快捷键

    1.F10,F11 单步调试 2.Ctrl + / :注释/取消注释选定内容. 3.F4 :在 头文件(.h) 和 实现文件(.cpp) 之间进行切换. 4.Ctrl + i :自动格式化选中代码. ...

  2. blogCMS整理

    一.在urls中写路由 二.返回登录页面(login.html中写前端代码) - username(用户名) - password(密码) - validCode(验证码) -submit(提交按钮) ...

  3. Memcached基础介绍

    1.memcached是什么,有什么作用? )memcached是一个开源的.高性能的内存的缓存软件,从名称上看mem就是内存的意思,而cache就是缓存的意思. )memcached通过在事先规划好 ...

  4. 在python中有多少种运算符?解释一下算术运算符

    在python中,我们有7种运算符:算术运算符.关系运算符.赋值运算符.逻辑运算符.位运算符.成员运算符.身份运算符 我们有7个算术运算符,能让我们对数值进行算术计算 1.加号(+),将两个值相加 2 ...

  5. WinForm下的Nhibernate+Spring.Net的框架配置文件

    1.先将配置文件放到如下:<?xml version="1.0" encoding="utf-8"?> <configuration> ...

  6. 数据结构&算法(一)_堆、栈(堆栈)、队列、链表

    堆: ①堆通常是一个可以被看做一棵树的数组对象.堆总是满足下列性质: ·堆中某个节点的值总是不大于或不小于其父节点的值: ·堆总是一棵完全二叉树.将根节点最大的堆叫做最大堆或大根堆,根节点最小的堆叫做 ...

  7. shiro 拦截器

    参考

  8. C/C++中0xcccccccc...

    * 0xABABABAB : Used by Microsoft's HeapAlloc() to mark "no man's land" guard bytes after a ...

  9. Linux下的查找命令which、whereis、locate、find(6/20)

    Linux下查找相关命令主要有以下4个:which.whereis.locate.find. (1)which   [-a]    cmdname1 cmdname2 ...... 命令参数: -n  ...

  10. 认识shiro

    shiro是安全(权限)框架,不仅可以在javase中也可以在javaee中 shiro可以完成认证.授权.加密.会话管理,与web进行集成.缓存等. Authentication:身份认证/登录,验 ...