zoukankan      html  css  js  c++  java
  • JEECG开发第一个菜单显示设备列表

    一、新建设备表(t_base_device)

    复制代码
    SET FOREIGN_KEY_CHECKS=0;
    
    -- ----------------------------
    -- Table structure for t_base_device
    -- ----------------------------
    DROP TABLE IF EXISTS `t_base_device`;
    CREATE TABLE `t_base_device` (
      `deviceid` int(10) NOT NULL,
      `devicecode` varchar(50) DEFAULT NULL,
      `devicename` varchar(50) DEFAULT NULL,
      `deviceclassno` varchar(10) DEFAULT NULL,
      `status` varchar(10) DEFAULT NULL,
      `username` varchar(50) DEFAULT NULL,
      `userdept` varchar(200) DEFAULT NULL,
      PRIMARY KEY (`deviceid`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
    
    -- ----------------------------
    -- Records of t_base_device
    -- ----------------------------
    INSERT INTO `t_base_device` VALUES ('10001', 'STPC201711001', '华硕X550', '0101', '使用中', '谢红卫', '软件研发部');
    INSERT INTO `t_base_device` VALUES ('10002', 'STPC201711002', '联想T440P', '0101', '库存', null, null);
    复制代码

    二、实体类(BaseDevice.java)

    复制代码
    package net.xhw.device.entity;
    
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.Id;
    import javax.persistence.Table;
    
    @SuppressWarnings("serial")
    @Entity
    @Table(name = "t_base_device")
    public class BaseDevice implements java.io.Serializable{
    
        private int deviceid;
        private String devicecode;
        private String devicename;
        private String deviceclassno;
        private String status;
        private String username;
        private String userdept;
        
        @Id
        @Column(name = "deviceid", length = 10)
        public int getDeviceid() {
            return deviceid;
        }
        
        @Column(name = "devicecode", length = 50)
        public String getDevicecode() {
            return devicecode;
        }
        
        @Column(name = "devicename", length = 50)
        public String getDevicename() {
            return devicename;
        }
        
        @Column(name = "deviceclassno", length = 10)
        public String getDeviceclassno() {
            return deviceclassno;
        }
        
        @Column(name = "status", length = 10)
        public String getStatus() {
            return status;
        }
        
        @Column(name = "username", length = 50)
        public String getUsername() {
            return username;
        }
        
        @Column(name = "userdept", length = 200)
        public String getUserdept() {
            return userdept;
        }    
        
        public void setDeviceid(int deviceid) {
            this.deviceid = deviceid;
        }
        
        public void setDevicecode(String devicecode) {
            this.devicecode = devicecode;
        }
        
        public void setDevicename(String devicename) {
            this.devicename = devicename;
        }
        
        public void setDeviceclassno(String deviceclassno) {
            this.deviceclassno = deviceclassno;
        }
        
        public void setStatus(String status) {
            this.status = status;
        }
        
        public void setUsername(String username) {
            this.username = username;
        }
        
        public void setUserdept(String userdept) {
            this.userdept = userdept;
        }    
        
    }
    复制代码

    三、action控制类(DeviceController.java)

    复制代码
    package net.xhw.device.ctrl;
    
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.jeecgframework.core.common.controller.BaseController;
    import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery;
    import org.jeecgframework.core.common.model.json.DataGrid;
    import org.jeecgframework.tag.core.easyui.TagUtil;
    import org.jeecgframework.web.system.service.SystemService;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.servlet.ModelAndView;
    import net.xhw.device.entity.BaseDevice;
    
    
    @Controller
    @RequestMapping("/deviceController")
    public class DeviceController extends BaseController {
        
        private SystemService systemService;
        
        @Autowired
        public void setSystemService(SystemService systemService) {
            this.systemService = systemService;
        }
    
        @RequestMapping(params = "deviceList")
        public ModelAndView deviceList(HttpServletRequest request) {
            return new ModelAndView("device/deviceList");
        }
        
        @RequestMapping(params = "datagrid")
        public void datagrid(BaseDevice basedevice, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {        
            CriteriaQuery cq = new CriteriaQuery(BaseDevice.class, dataGrid);
            this.systemService.getDataGridReturn(cq, true);
            TagUtil.datagrid(response, dataGrid);
        }
        
    }
    复制代码

    四、页面文件(deviceList.jsp)

    复制代码
    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    <%@include file="/context/mytags.jsp"%>
    <t:base type="jquery,easyui,tools,DatePicker"></t:base>
    
    <t:datagrid name="deviceList" title="设备信息列表" actionUrl="deviceController.do?datagrid" 
        fit="true" fitColumns="true" idField="deviceid" queryMode="group">
        <t:dgCol title="设备ID" field="deviceid" hidden="true"></t:dgCol>
        <t:dgCol title="设备编码" field="devicecode" query="false" width="100"></t:dgCol>
        <t:dgCol title="设备名称" field="devicename" query="false" width="100"></t:dgCol>
        <t:dgCol title="状态" field="status" query="false" width="100"></t:dgCol>
        <t:dgCol title="使用人" field="username" query="false" width="100"></t:dgCol>
    </t:datagrid>
    复制代码

    五、修改配置文件

      1、修改spring-mvc.xml,添加扫描控制类包    

    <context:component-scan base-package="org.jeecgframework.web.*,com.jeecg.*,net.xhw.*">
      <context:exclude-filter type="annotation"
         expression="org.springframework.stereotype.Service" />
    </context:component-scan>

      2、修改spring-mvc-hibernate.xml,添加注解方式配置

    复制代码
    <!-- 注解方式配置 -->
    <property name="packagesToScan">
      <list>
         <value>org.jeecgframework.web.system.pojo.*</value>
         <value>org.jeecgframework.web.test.entity.*</value>
        <value>org.jeecgframework.web.autoform.*</value>
        <value>org.jeecgframework.web.cgform.entity.*</value>     <value>org.jeecgframework.web.cgreport.entity.*</value>     <value>org.jeecgframework.web.cgdynamgraph.entity.*</value>     <value>org.jeecgframework.web.graphreport.entity.*</value>     <value>org.jeecgframework.web.system.sms.*</value>     <value>com.jeecg.*</value>     <value>net.xhw.*</value> </list> </property>
    复制代码

    六、菜单配置及结果

  • 相关阅读:
    第十周(11.18-11.24)----结对编程----感悟
    第十周(11.18-11.24)----分数计算----(2)对两个分数进行加减乘除
    第十周(11.18-11.24)----规格说明书练习----吉林市1日游
    浪潮之巅读后感
    闽江学院软件学院2015级学生职业人物访谈
    第五作业
    第4周~第12周周记
    兴趣问题清单
    学习进度
    价值观作业
  • 原文地址:https://www.cnblogs.com/Jeely/p/12612623.html
Copyright © 2011-2022 走看看