Java handles bulk data submissions

Source: Internet
Author: User

In the Java Web development process, processing form data is an important part of the common is the form post processing a single piece of data, but also encountered one time to submit multiple data to the server, as follows:

JSP page is generally used in the loop Insert input box, and all the ID and name is the same prefix, convenient server access

1 <  items= "${objlist}"  var= "obj">2     < id = "key_${obj."   Id} "  name=" key_${obj. Id} "/>3</c:foreach>

Server-side Get parameter code:

1@RequestMapping (value = "/xxxsave", method =requestmethod.post)2  PublicString Paypropssave (FinalHttpServletRequest Request) {3 4     FinalEnumeration<string> enums =Request.getparameternames (); //Get request all parameters 5 6     FinalList<obj> objlist =NewArraylist<obj>();7 8      while(Enums.hasmoreelements ()) {9         FinalString paramname =enums.nextelement (). toString ();Ten         if(Paramname.startswith ("Key_") {//filter all parameters starting with Key_ One             FinalString Elementvalue =Request.getparameter (paramname); A             Finalobj obj =NewObj (); - Obj.setid (elementvalue); -             . the             . -             . - Objlist.add (props); -         } +     } -  + objservice.saveobjlist (objlist); A     ... at     ... -     ... -  - return"XXX"; -  -}

The above is the accumulation of work, if there is a problem, please discuss correct, reprint annotated address

Java handles bulk data submissions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.