2. Create the first Demo to display the database to the page. Step 1. create a MySQL database table 2. integrate the SSH framework 3. key notes for using ExtJS: Ext. data. the meaning of root in JsonReader. For example, the root attribute of JSON returned by the request action should be set as follows: root: list1, MySQL database created, 2-1
2. Create the first Demo to display the database to the page. Step 1. create a MySQL database table 2. integrate the SSH framework 3. key notes for using ExtJS: Ext. data. the meaning of root in JsonReader. For example, the root attribute of JSON returned by the request action should be filled in as follows: root: list 1. Create MySQL database, 2-1
2. Create the first Demo to display the database to the page.
Step: 1. Create a MySQL database table
2. Integrate the SSH framework
3. Use ExtJS to display
Key notes:
The root meaning in Ext. data. JsonReader, for example, the JSON returned by the request action
In this case, the root attribute should be filled in as follows: root: list
1. Create a MySQL database, as shown in Figure 2-1.
-1
2. Integrate the SSH framework
Because ExtJS processes JSON data, the action should be returned in JSON format.
Action class:
package com.hanhexin.action;import java.util.ArrayList;import java.util.List;import org.apache.struts2.convention.annotation.Result;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.context.annotation.Scope;import org.springframework.stereotype.Component;import com.hanhexin.entity.Person;import com.hanhexin.service.IPersonService;import com.opensymphony.xwork2.ActionSupport;@Component("personAction")@Scope("prototype")public class PersonAction extends ActionSupport{private Person person;@Autowiredprivate IPersonService personService;List
list = new ArrayList
();public String list(){person = new Person();list = personService.getListByPerson(person, 1, 10);System.out.println(list.size()+"action+++++++++++++++++++++");return SUCCESS;}public List
getList() {return list;}public void setList(List
list) {this.list = list;}}
Configure the struts. xml file to return JSOn, as shown below:
Be sure to set
...
3. Use ExtJS to display the JSP file on the page as follows:
<% @ Page language = "java" import = "java. util. * "pageEncoding =" UTF-8 "%> <% @ taglib uri ="/struts-tags "prefix =" s "%> My JSP 'main. jsp 'starting page