当前位置:网站首页>Web资源共享
Web资源共享
2022-07-22 21:48:00 【delighted_qian】
1、Request实现请求转发(与下面的Response实现重定向 区分)

请求转发资源共享数据:使用Request对象
void setAttribute(String name,Object o)存储数据到request域中
Object getAttribute(String name) 根据key 获取值
void removeAttribute(Sting name) 根据key,删除该键值对
案例 web-demo01


2、Response实现重定向
response.sendRedirect("/web-demo01/resp02");案例 web-demo01

3、Cookie

4、Session
\
1 brand-demo的增 删 该都是用的request的
request.getRequestDispatcher("/selectAllServlet").forward(request,response);2 brand-demo查询的用的是 只是存上了数据
// 封装到request域中
request.setAttribute("brand",brand);
// 转发
request.getRequestDispatcher("update.jsp").forward(request,response);3 brand-demo的登录页面用的是
登陆成功 Session资源共享
// session共享资源
HttpSession session = request.getSession();
session.setAttribute("user",user);
// 实现重定向
response.sendRedirect("/brand-demo/selectAllServlet");我自己想的
// request.setAttribute("login_name", user.getUsername());
// request.getRequestDispatcher("/selectAllServlet").forward(request, response);登陆失败 用的是
// 存储信息到request域
request.setAttribute("login_msg", "用户名或密码错误");
// 转发
request.getRequestDispatcher("/login.jsp").forward(request, response);我自己想的
// HttpSession session = request.getSession();
// session.setAttribute("login_msg","用户名或密码错误");
// response.sendRedirect("/brand-demo/login.jsp");4 brand-demo的登录页面验证码用的是Cookie
//用户勾选了记住用户
Cookie c_username = new Cookie("username", username);
Cookie c_password = new Cookie("password", password);
//记住时间
c_username.setMaxAge(60*60*24*7);
c_password.setMaxAge(60*60*24*7);
//发送Cookie
response.addCookie(c_username);
response.addCookie(c_password);边栏推荐
- About redis, do you update the database first or the cache first?
- [record of question brushing] 18. Sum of four numbers
- 如何配置CANoe Network-based access模式的以太网网络拓扑
- 如何在 PHP 应用程序中预防SQL 注入
- SLAAC 无状态地址自动配置
- 初出茅庐的小李第111篇博客之中英文点阵字符显示原理
- 【干货原创】发现了一个好用到爆的数据分析利器
- Simulate not all endpoints registered exceptions and Solutions
- 我在京东使用工厂模式,一文说清楚工厂模式
- 数据脱敏的场景与价值【总结】
猜你喜欢

浅谈性能优化:APP的启动流程分析与优化

机器学习笔记 - 基于深度学习(HomographyNet)的图像单应性估计

老板要我做一个 IP 属地功能,一个开源库搞定!

初出茅庐的小李第108篇博客二进制打印

How to open the file in keil is the real path in the 109th blog of fledgling Xiao Li

【刷题记录】18. 四数之和

实验三 LZW

QT document reading notes - qaudioinput & qaudioformat parsing and examples

数据库基础及安装

ROS based navigation framework
随机推荐
数据脱敏的场景与价值【总结】
使用路由协议配置 IPv6 over IP手动隧道
Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
flink批量读取es
Fledgling Xiao Li's 108th blog binary print
二冲程发动机均值模型仿真
About redis, do you update the database first or the cache first?
PNY file to picture
Topic domain model
LAN SDN technology hard core insider 6 distributed anycast gateway
VMware虚拟机更改静态IP和主机名,使用Xshell进行连接
Experiment 4 DPCM
开幕在即 | “万物互联,使能千行百业”2022开放原子全球开源峰会OpenAtom OpenHarmony分论坛
Rust——关于Option详解
Scala Generic 泛型类详解 - T
Mysql A left(right) join B on A.id=B. ID and a.age=1 and a left (right) join b on a.id=b id where A.age=1
延伸联接边界,扩展业务范围,全面迈向智能云网2.0时代
LAN SDN technology hard core insider 7 from layer 2 to layer 2
Worthington对肝细胞分离系统的测试及相关优化方案
弥散张量分析开源软件 DSI Studio 简体中文汉化版可以下载了