07-请求重发--jsp文件
package com.resquest;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/*
* requset 作用域 该对象可以在一个请求中传输数据 左右方位 在一次请求中有效,即服务器跳转有效
* 设置域对象内容
* requset.setAttribute(String name);
* 获取域对象
* request.getSttribute(String name);
* 删除域对象内容
* request.removeAttribute(String name);
*
* */
@WebServlet("/ser05")
public class servlet05 extends HttpServlet {
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("05------");
// 设置域对象内容
request.setAttribute("name","admin");
request.setAttribute("age",18);
List<String> list = new ArrayList<>();
list.add("aaa");
list.add("bbb");
request.setAttribute("list",list);
// 转发到 06
// request.getRequestDispatcher("ser06").forward(request,response);
// 转发 到 login.jsp
request.getRequestDispatcher("login.jsp").forward(request,response);
}
}