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