发布网友 发布时间:2022-05-01 23:05
共3个回答
懂视网 时间:2022-05-02 03:27
ajax <script type="text/javascript"> function findsc(){ $(‘#metable‘).empty(); $.ajax({ url: "find", type: "get", data:{ key:$(‘#keywords‘).val() }, success:function(data){ alert(data); $(‘#metable‘).append(data); } }); } </script> //servlet关键 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub response.setContentType("text/html;charset=utf-8"); response. setCharacterEncoding("UTF-8"); response.getWriter().append("Served at: ").append(request.getContextPath()); MyServiceDao myServiceDao=new MyServiceDao(); List<Sc> temp; PrintWriter outme=response.getWriter(); outme.print("<tr><td style=‘background:#FFF68F;‘>学号</td><td style=‘background:#FFF68F;‘>姓名</td><td style=‘background:#FFF68F;‘>语文</td><td style=‘background:#FFF68F;‘>数学</td><td style=‘background:#FFF68F;‘>英语</td><tr>"); try { temp=myServiceDao.getScByName(request.getParameter("key")); for(Sc sc : temp){ outme.print( "<tr><td style=‘background:#CAFF70;‘>"+sc.getId() +"</td><td style=‘background:#CAFF70;‘>"+sc.getName() +"</td><td style=‘background:#CAFF70;‘>"+sc.getYuwen() +"</td><td style=‘background:#CAFF70;‘>"+sc.getShuxue() +"</td><td style=‘background:#CAFF70;‘>"+sc.getYingyu() +"</td><tr>" ); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } outme.close(); }
ajax交互servlet返回数据和jdbc模糊查询-中文-已经设置了UTF-8和解决了乱码
标签:iso 结果 get clip 表单 ... 数据 传递数据 工程
热心网友 时间:2022-05-02 00:35
我用*解决了这个问题热心网友 时间:2022-05-02 01:53
表单提交到后台有乱码解决: