发布网友 发布时间:2022-04-09 22:08
共6个回答
懂视网 时间:2022-04-10 02:29
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-04-09 23:37
ajax 是依靠xmlHttpRequest 对象来异步发送请求热心网友 时间:2022-04-10 00:55
请问您怎么解决的,我一直没有搞定这个乱码问题 !热心网友 时间:2022-04-10 02:30
request.setCharacterEncoding("utf-8");参考资料:www.javaview.cn
热心网友 时间:2022-04-10 04:21
String name = request.getp....("getName");热心网友 时间:2022-04-10 06:29
用post提交时中文解决办法: