protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//向request域中存值
request.setAttribute("name", "张三" );
//请求转发
request.getRequestDispatcher("/Servlet02").forward(request, response);
}
public class Servlet02 extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//从request 域中取值
String name =(String)request.getAttribute("name");
//解决中文乱码
response.setContentType("text/html;charset=utf-8");
response.getWriter().write("hello"+name);
}
Linux公社的RSS地址:https://www.linuxidc.com/rssFeed.aspx