@WebServlet("/test")
public class TestServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
ArrayList<String> strList = new ArrayList<>();
strList.add("老六");
strList.add("老八");
strList.add("王二麻子");
request.setAttribute("strList", strList);
User user = new User("六爷", 23);
request.getSession().setAttribute("user", user);
response.sendRedirect(this.getServletContext().getContextPath() + "/result.jsp");
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doGet(req, resp);
}
}
The result.jsp page code is as follows
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>使用EL从域对象中获取结果</title>
</head>
<body>
<%--获取List集合的第一个元素--%>
${strList[0]}
<%--获取User对象的username--%>
${user.username}
</body>
</html>
Ask what is displayed ________________;