Layui Interactive Data Acquisition Java

Source: Internet
Author: User

Layui Introduction

Layui is a UI framework for background programmers with low learning costs. The JSON data format interacts with the front and back tables and is also quite suitable for single page development. Interested friends can take a look at Layui official website.

Layui data interaction between the front and rear tables

Layui has its own set of specific data format interactions (which is important) and must have parameters Code:0,msg: "", Count: Data size (int), Data: "List". Generally we choose to encapsulate the returned receive class.
Layui Front desk JS request data
where the HTML code

<LinkRel="Stylesheet"href= "Static/layui/css/layui.css" media= "all"/><script type=" Text/javascript "src=" static/layui/layui.js "> </script>< table class= "Layui-hide" id= "test" lay-filter=" table "></TABLE>     
    • 1
    • 2
    • 3

JS Code

Layui.use ([' Form ',' Layer ',' Table '],function(){var table = layui.table, form = layui.form,$=layui.$; Table.render ({elem:' #test 'Bind table ID, URL:' Sys/menu/list 'Data request path, Cellminwidth:COLS: [[{type:' Numbers '}, {field:' Name ', title:' Menu Name '}, {field:' ParentName ', title:' Parent menu Name ', Width:, {field:' URL ', title:' Menu Path '}, {field:' Perms ', title:' Menu Permissions '}, {field:' Type ', title: ' icon ', Title: ' icon '}, {Field: ' Ordernum ', Title: ' sort '}, {fixed:  ' operation ', Width:180, Align: ' #toolBar '} //a toolbar for details, see the Layui website]] , page: true //open paging, Limit:10 //default 10 data page, Limits:[10,20,30,50" //data paging bar, ID:               
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21st
    • 22
    • 23
    • 24
    • 25

Java Background Code

@RequestMapping ("/list") @ResponseBody @RequiresPermissions ("Sys:menu:list")Public LayuiList (@RequestParamMap<String, Object>params) {//query list data query query for = new query ( Span class= "Hljs-keyword" >params); list<sysmenuentity> Menulist = sysmenuservice.querylist (query); int total = sysmenuservice.querytotal (query); Pageutils pageutil = new pageutils (MenuList, Total, Query.getlimit (), Query.getpage ()); return layui. Data (Pageutil.gettotalcount (), Pageutil.getList ());}   
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

Layui Tool Class Code

public  Span class= "Hljs-class" >class layui extends hashmap<String, object> {public static Layui data ( Integer count,list<?> data) {Layui R = new Layui (); R.put ( "code", 0), R.put ( "MSG", Span class= "hljs-string" "" "); R.put ( "Count", Count), R.put ( "data", data); return R; }} 
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

Pageutils here is dispensable, you can package yourself

@DataPublicClassPageutilsImplementsSerializable {PrivateStaticFinalLong Serialversionuid =-1202716581589799959L;Total Record CountPrivateint totalcount;Number of records per pagePrivateint pageSize;Total pagesPrivateint totalpage;Current pagePrivateint currpage;List dataprivate list<?> List; /** * pagination * @param list data * @param pageSize number of records per page * @param Currpage Current Page */public pageutils (list<?> List, int totalcount, int pageSize, int currPage) { Span class= "Hljs-keyword" >this.list = list; this.totalcount = TotalCount; this.pagesize = pageSize; this.currpage = currpage; this.totalpage = (int) Math.ceil (( double) totalcount/pagesize); }} 
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21st
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30

In a word, the last Layui to receive the data format for

Turn from 78944591

Layui Interactive Data Acquisition Java

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.