Array assignment understanding error, resulting in data errors

Source: Internet
Author: User

Scenario: Demand export data.

Specific function: Export data according to the results of the query, if you do not tick the data that needs to be exported, export all data if checked, then export the data selected in the query results.

Implementation method: In the query, the generated query conditions are placed in the session, the query condition is a collection, when the export to get the query conditions and the ID of the selected data, generating a new query criteria.

Problem: The first time the data is exported correctly, the second export when the query condition in the session is the first time generated query conditions, resulting in the result of the export of this condition and the result of the previous condition

Cause of error: The concept of copying and assigning an array is unclear. The following is the code

Correct code:

List searchparams = (list) request.getsession (). getattribute ("Searchquitassetparamslist");         New ArrayList ();  for (Object param:searchparams) {paramslist.add (param);
}
= Request.getparameter ("IDs"); if null &&! "" = ids.substring (0, Ids.length ()-1); Paramslist.set (6, Paramslist.get (6) + "and asset_id in (" + IDs + ")"= Assetquitservice.getassetquit ( null null);

Error code:

= (List) request.getsession (). getattribute ("Searchquitassetparamslist");
For


= Request.getparameter ("IDs"
if null &&! ""
= ids.substring (0, Ids.length ()-1
Paramslist.set (6, Paramslist.get (6) + "and asset_id in (" + IDs + ")"

= Assetquitservice.getassetquit (nullnull);

Array assignment understanding error, resulting in data errors

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.