request.setAttribute("username", username);//一定要保存,OGNL才能获取${username}
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}的更多相关文章
- request.getAttribute( "result");和request.setAttribute("result",username);
request.setAttribute("result",username);在request对象中加入名为result的属性并附值为username,因为request对象是可 ...
- 如何获得 request, "request.getSession(true).setAttribute("a",a);"与“request.setAttribute("a",a);”区别
protected ServletContext getServletContext() { return ServletActionContext.getServletContext();} pro ...
- request.setAttribute和request.getAttribute还有session.setAttribute和session.getAttribute还有request.getParameter和request.getAttribute区别和联系
1.session.setAttribute()和session.getAttribute()配对使用,作用域是整个会话期间,在所有的页面都使用这些数据的时候使用. 2.request.setAttr ...
- request.getParameter()与request.setAttribute()的区别 (转载)
request.getParameter()与request.setAttribute()的区别 request.getParameter(),request.setAttribute()区别如下: ...
- request.setAttribute()、session.setAttribute()和request.getParameter()的联系与区别(记录)
1.session.setAttribute()和session.getAttribute()配对使用,作用域是整个会话期间,在所有的页面都使用这些数据的时候使用. 2.request.setAttr ...
- request.getSession().setAttribute("",..)和request.setAttribute("",...)的差别
request.getSession.setAttribute()是获得当前会话的session,然后再setAttribute到session里面去,有效范围是session而不是request. ...
- request.setAttribute()、session.setAttribute()和request.getParameter()的联系与区别
1.session.setAttribute()和session.getAttribute()配对使用,作用域是整个会话期间,在所有的页面都使用这些数据的时候使用. 2.request.setAttr ...
- javaweb: request.getParameter()、request.setAttribute()与request.getAttribute()的作用 (转)
出处:https://blog.csdn.net/qq_41937388/article/details/87972914 1.request.getParameter()方法是获取通过类似post, ...
- request.setAttribute()用法
小问题: JSP1代码 String [] test=new String[2]; test[0]="1"; test[1]="2"; request.setA ...
随机推荐
- 对数值数据的格式化处理(保留小数点后N位)
项目中有时会遇到对数值部分进行保留操作,列如保留小数点后2位,所有的数据都按这种格式处理, //保留小数点后2位,都按这种格式处理,没有补0 DecimalFormat df = new Decima ...
- HTTP状态码集
1xx消息 这一类型的状态码,代表请求已被接受,需要继续处理.这类响应是临时响应,只包含状态行和某些可选的响应头信息,并以空行结束.由于HTTP/1.0协议中没有定义任何1xx状态码,所以除非在某些试 ...
- python并发编程之IO模型(Day38)
一.IO模型介绍 为了更好的学习IO模型,可以先看同步,异步,阻塞,非阻塞 http://www.cnblogs.com/linhaifeng/articles/7430066.html#_label ...
- 解决XAMPP不能启动Apche服务问题
打开command prompt输入命令 netstat -ano 查看哪个 PID的进程占用了80端口.结果是inetinfo.exe 网上查了下,正是WIN XP IIS的进程,但是又不想删,就只 ...
- iPhone获取手机里面所有的APP(私有库)+ 通过包名打开应用
1.获取到手机里面所有的APP包名 - (void)touss { Class lsawsc = objc_getClass("LSApplicationWorkspace"); ...
- spring boot集成redis缓存
spring boot项目中使用redis作为缓存. 先创建spring boot的maven工程,在pom.xml中添加依赖 <dependency> <groupId>or ...
- Java基础_基本语法
Java基本语法 一:关键字 在Java中有特殊含义的单词(50). 二:标志符 类名,函数名,变量名的名字的统称. 命名规则: 可以是字母,数字,下划线,$. 不能以数字开头. 见名之意. 驼峰规则 ...
- 一般处理程序中 C#中对象转化为Json对象
namespace: Newtonsoft.Json; context.Response.ContentType = "application/text"; 注:这里为什么不是 J ...
- MySQL 数据(数据库)迁移
查找MySQL真正的Data目录 show variables like 'datadir'; +---------------+-----------------+ | Variable_name ...
- SQL中比较好的For xml 用法实例
--包裹单号 入库时间 交易号 商品分类 商品名称 实付款SELECT a.DeliveryCode AS '包裹单号',a.DomesticWarehouseInTime AS '入库时间',a.T ...