关于批量删除和Ajax数组传参时候遇到的问题

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_41955968/article/details/81097147

第一篇博客:

今天在工作上有一个批量删除的功能,自己在最开始写的所有删除的时候都是单条进行删除,但是最好的都是既能单条删除也能多条删除,有两种方法。个人推荐第二种,因为第一种是一条sql根据id进行单条删除,然后在controller层进行遍历id,这样的话就是导致了每循环一次就在数据库里进行一次查询。这样是sql的大忌。如下:

dao层的代码

controller层代码

这种也可以达到效果但是效率低了很多;

第二种:代码如下

dao层代码:

controller层代码

这样效率就提高了很多;

再附上测试批量删除的Ajax 数组传参时候的写法:其中传数组的时候traditional:true,//这个参数必须加,传数组的时候

展开阅读全文

关于ajax传参问题!!急!!

11-15

我写了个jsp文件和一个servlet,具体代码如下:rngetAndPostExample.jsprnrnrnrn rnrnrn Enter your first name,middle name,and birthday:rn rn rn rn First name:rn rn rn rn Middle name:rn rn rn rn Birthdayrn rn rn rn rn rn rn rn rn rn rn Server Response:rn rn rnrnrnGetAndPostExample.javarnpackage test;rnrnimport java.io.IOException;rnimport java.io.PrintWriter;rnrnimport javax.servlet.ServletException;rnimport javax.servlet.http.HttpServlet;rnimport javax.servlet.http.HttpServletRequest;rnimport javax.servlet.http.HttpServletResponse;rnrnpublic class GetAndPostExample extends HttpServlet rnrn public void doGet(HttpServletRequest request, HttpServletResponse response)rn throws ServletException, IOException rnrn processRequest(request, response, "GET");rn rnrn public void doPost(HttpServletRequest request, HttpServletResponse response)rn throws ServletException, IOException rnrn processRequest(request,response,"POST");rn rnrn protected void processRequest(HttpServletRequest request,rn HttpServletResponse response, String method) throws IOException rnrn response.setContentType("text/xml");rn String firstName = request.getParameter("firstName");rn String middleName = request.getParameter("middleName");rn String birthday = request.getParameter("birthday");rn String responseText = "Hello " + firstName + " " + middleNamern + " Your birthday is " + birthday + "." + "[Method: " + methodrn + "]";rn PrintWriter out = response.getWriter();rn out.println(responseText);rn out.close();rnrn rnrnrn可是当点击按钮的时候出不来我输入的东西,出来的东西很奇怪,如下:rn Apache Tomcat/5.0.28 - Error report HTTP Status 404 - /test/GetAndPostExample type Status report message /test/GetAndPostExample description The requested resource (/test/GetAndPostExample) is not available. Apache Tomcat/5.0.28rn请问各位大侠这是什么错误啊??rn 论坛

没有更多推荐了,返回首页