08-接受转发请求数据--数组
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 javax.swing.*;
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("/ser06")
public class servlet06 extends HttpServlet {
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("06------");
// 设置域对象内容
String name = (String) request.getAttribute("name");
Integer age = (Integer) request.getAttribute("age");
List<String> list = (List<String>) request.getAttribute("list");
System.out.println("name"+name+"-----age"+age+"----list"+list.get(0));
}
}