a.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <form method="post" action="b.jsp"> <input type="text" id="name" name="name"> <input type="submit"> </form> </body> </html>
b.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <% //解决乱码问题 request.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8"); String name = request.getParameter("name"); System.out.println(name); session.setAttribute("flag",name); response.sendRedirect("c.jsp"); %>
c.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <% Object name = session.getAttribute("flag").toString(); %> <html> <head> <title>Title</title> </head> <body> <%=name%> </body> </html>