如何使用AJAX从servlet发送List <>到jsp并想将获取的List添加到jsp的列表中

时间:2018-08-27 16:35:42

标签: ajax jsp servlets

ajax,它是从文本框中获取数据并发送到servlet

$(document).ready(function () {
            $('#nm').blur(function () {
                $.ajax({
                    url: 'sign',
                    data: {
                        checkname: $('#nm').val()
                    },
                    success: function (responseText) {
                        $('#msg').text(responseText);
                    }
                });
            });
        });

如果产品存在,则为servlet,该产品的所有详细信息都将添加到列表中

 String chkname = request.getParameter("checkname");
            Object ob = "";
            try {
                System.out.println("name is " + chkname);
                Configuration cone = new Configuration().configure().addAnnotatedClass(nameseenpojo.class);
                ServiceRegistry sreg=new StandardServiceRegistryBuilder().applySettings(cone.getProperties()).build();
                SessionFactory sfec = cone.buildSessionFactory(sreg);
                Session ses = sfec.openSession();
            nameseenpojo np = (nameseenpojo) ob;
            if (np.getName().contains(chkname)) {
    Query q = sess.createQuery("from " + nameseenpojo.class.getSimpleName());
               li = q.list();
                response.setContentType("text/plain");
            }

如何使用响应将列表从servlet发送到jsp,以及如何将列表添加到jsp中的给定列表

0 个答案:

没有答案