Web_Servlet和jsp页面数据交互,通过请求转发在jsp中显示数据

2021-01-29 15:16

阅读:448

YPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">

标签:color   content   exception   存储   xtend   title   exce   mic   servlet   

1.Servlet页面代码

/*
    实现jsp页面和sevlet页面的信息交互
 */
@WebServlet(urlPatterns = "/aa")
public class JspService extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //以键值对存储数据

        request.setAttribute("name","张三丰");

        //进行页面跳转,把信息传过去
        request.getRequestDispatcher("/demojsp.jsp").forward(request,response);

    }
}

2.Jsp页面

Title

 

Web_Servlet和jsp页面数据交互,通过请求转发在jsp中显示数据

标签:color   content   exception   存储   xtend   title   exce   mic   servlet   

原文地址:https://www.cnblogs.com/LVowe/p/13202083.html


评论


亲,登录后才可以留言!