SSM distributed Architecture e-commerce project-07 backend Management system Query the product list and the writing of the journal

Source: Internet
Author: User
Check Product List JS

formatted output of the Easyui DataGrid

By default, the returned data is displayed directly, but in some cases it cannot be displayed directly, such as price, date, gender, and the formatter function needs to be specified.

Background Implementation Controller

  /**
     * Check Product list
     * 
     * @param page
     * @param rows
     * @return
     *
    /@RequestMapping (method = requestmethod.get) Public
    responseentity<easyuiresult> queryitemlist (
            @RequestParam (value = "Page" , DefaultValue = "1") integer page,
            @RequestParam (value = "Rows", DefaultValue = "") integer rows) {
        try {
  return Responseentity.ok (this.itemService.queryItemList (page, rows));
        } catch (Exception e) {
            e.printstacktrace ();
        }
        Return Responseentity.status (Httpstatus.internal_server_error). body (null);
    }
Service

Public easyuiresult queryitemlist (integer page, integer rows) {

        //Set paging parameter
        pagehelper.startpage (page, rows);

        Example Example = new Example (item.class);
        Installation creation time sort
        example.setorderbyclause ("created DESC");
        list<item> items = this.itemMapper.selectByExample (example);

        pageinfo<item> PageInfo = new pageinfo<item> (items);

        return new Easyuiresult (Pageinfo.gettotal (), pageinfo.getlist ());
    }
Easyuiresult
Package Com.taotao.common.bean;

Import java.util.List;

public class Easyuiresult {

    private Long total;

    Private list<?> rows;

    Public Easyuiresult () {

    } public

    Easyuiresult (Long total, list<?> rows) {
        this.total = total;
        this.rows = rows;
    }

    Public Long gettotal () {
        return total;
    }

    public void Settotal (Long total) {
        this.total = total;
    }

    Public list<?> getRows () {
        return rows;
    }

    public void Setrows (list<?> rows) {
        this.rows = rows;
    }

}
Test

writing of the journal

    private static final Logger Logger = Loggerfactory.getlogger (Itemcontroller.class); @RequestMapping (method = requestmethod.post) public responseentity<void> SaveItem (item item, @RequestParam ("des   C ") String desc) {try {if (logger.isdebugenabled ()) {Logger.debug (" new Item, item = {},
            desc = {} ", item, DESC); } if (Stringutils.isempty (Item.gettitle ())) {//TODO not completed, to be optimized//parameter wrong, + RET
            Urn Responseentity.status (httpstatus.bad_request). build ();
            }//Save commodity Boolean bool = This.itemService.saveItem (item, DESC);
                if (!bool) {if (logger.isinfoenabled ()) {Logger.info ("New product failed, item = {}", item); }//Save failed return Responseentity.status (httpstatus.internal_server_error). Bui
            LD (); } if (logger.isinfoenabled ()) {logger.inFO ("New product success, itemId = {}", Item.getid ());
        } return Responseentity.status (httpstatus.created). build (); } catch (Exception e) {logger.error ("New product Error!
        Item = "+ Item, E);
    } return Responseentity.status (Httpstatus.internal_server_error). build (); }

Summary:
1, the method must be in the parameter to print the parameters of
2, the state of business execution changes, need to print
3, the exception needs to print

Related Article

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.