The database Content foreground page in the Spring MVC framework Displays the full version of the "Get a list of events for database personnel"

Source: Internet
Author: User
Tags button type

1. Write a JSP page that includes the content to be displayed "people.jsp"

<!--

Here are three things to do:

1. Contains Text input box Query button query results display location (paging)

2. Include Action on button

-

<div>
<div class= "M-B-MD2" >
<form class= "Form-inline" id= "SearchForm2"
Name= "SearchForm2">

<div class= "Form-group" >

<div class= "padding" >
<span class= "H4" > Personnel recent events Query:</span> <input class= "Input-medium" id= "author" name= "Author" >
</div>
</div>
<a href= "javascript:void (0)" class= "btn btn-info" id= "SEARCH2"> Query </a>
</form>
</div>
<div class= "doc-buttons" style= "padding:10px 0" >
<c:foreach items= "${res}" var= "key" >
<button type= "button" id= "${fn:split (key.btn, ', ') [0]}" name= "${fn:split (key.btn, ', ') [1]}" class= "${fn:split ( KEY.BTN, ', ') [2]} ">${fn:split (Key.btn, ', ') [3]}</button>
</c:forEach>
</div>
<div id= "paging2"Class=" ></div> "Pagclass2"
</div>

2. Entity class for new query operation entity is placed in entity package "Peopleformap.java"

/**

* This includes the table name to access the database and the table's primary key to map the database

*/

@TableSeg (tableName = "Test", id= "id")
public class Peopleformmap extends formmap<string,object>{
/**
*
*/
Private static final long serialversionuid = 1L;

}

3. The new service Layer service layer mainly includes the implementation of "Peopleservice.java" to add and delete changes.

Public interface Peopleservice extends baseservice{

}

4. The specific implementation of the new service "Peopleserviceimpl.java"

@Service ("Peopleservice")
public class Peopleserviceimpl extends Baseserviceimpl implements peopleservice{

}

5. New controller layer injects service into controller "Peoplecontroller.java"

Here you write the specific actions you want to invoke Peopleservice to perform

@Controller
@RequestMapping ("/people")
public class Peoplecontroller extends Basecontroller {
@Inject
Private Peopleservice Peopleservice;

@ResponseBody
@RequestMapping ("Peoplelist")
public string Peoplelist (String txtselect) throws Exception {

return common.background_path+ "/system/riskforcast/people";
}

@ResponseBody
@RequestMapping ("/findpeopleevents")
Public PageView findpeopleevents () {
map<string,object> result = new hashmap<> ();
Peopleformmap Peopleformmap = Getformmap (Peopleformmap.class);
PageView PageView = Getpageview (Peopleformmap);
Peopleformmap.put ("paging2", PageView);
Peopleformmap.put ("mapper_id", "Peopleservice".findpeopleevents");//Perform SQL operations id=findpeopleevents in mapper according to MAPPER_ID
list<peopleformmap> re = peopleservice.findbypage (Peopleformmap);//Implement database query through Findbypage in Peopleservice
Pageview.setrecords (re);
Result.put ("PageView", PageView);
return pageView;
}

6. The new mapper table mainly includes the SQL statement "People-mapper" executed against the database

<?xml version= "1.0" encoding= "UTF-8"?>
<! DOCTYPE Mapper Public "-//mybatis.org//dtd mapper 3.0//en"
"Http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace= "Peopleservice" >


<select id= "findpeopleevents" resulttype= "Com.lanyuan.entity.PeopleFormMap" >
SELECT * FROM Test
Where author is not null and author! = " //Query the test table for all data author field not empty
<if test= "Author! = null and author! =" ">
and author like '%${author}% '
</if>
</select>

</mapper>

7. Write JS page "People.js"

<!--JS page content 1. Write the Query method and initialize 2. The SQL statement path that you want to call 3. Fields you want to query

-

$ (document). Ready (function () {
Initeventlist (); Initialize method

function Initeventlist () {
Grid = Lygrid ({
Pagid: ' Paging2 ',
L_column: [
{
Colkey: "Author",
Name: "Event Propagator",
}, {
Colkey: "Page_title",
Name: "article title"
}, {
Colkey: "Refer_url",
Name: "Reprint Path"
}, {
Colkey: "Release_date",
Name: "Update Time"
}
],

Jsonurl:rootpath + '/people/findpeopleevents. shtml ',
Checkbox:true,
Sernumber:true
});
$("#SEARCH2"). Click (" click ", Function () {//Bind query button
var searchparams = $ ("#SearchForm2"). Serializejson ();//Initialization of parameters
Grid.setoptions ({
Data:searchparams
});
});
}

The database Content foreground page in the Spring MVC framework Displays the full version of the "Get a list of events for database personnel"

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.