Preliminary Exploration ExtJS (2)

Source: Internet
Author: User
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    
 

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.