jeecg的各種坑


1.數據字典,編碼長度不夠。搜索typegroup.jsp

<input name="typegroupcode" class="inputxt" validType="t_s_typegroup,typegroupcode,id" value="${typegroup.typegroupcode }" datatype="s2-20"> 
    <span class="Validform_checktip"><t:mutiLang langKey="common.code.range" langArg="common.code,common.range2to20"/></span></div>
datatype="s2-20"指定字符串長度2-20,langArg是提示的描述。在國際化里面。這里修改了,需要重啟項目,刷新緩存沒有用

2. 生成代碼,找不到數據庫;
jeecg/src/main/resources/dbconfig.properties
jeecg/src/main/resources/jeecg/jeecg_database.properties
這兩個文件配置要一致

3.項目名稱
select * from t_s_muti_lang where lang_key='jeect.platform'

4.首頁跳轉修改位置
jeecg\src\main\webapp\webpage\main\hplus_main.jsp
jeecg\src\main\webapp\webpage\main\fineui_main.jsp

五、數據權限
  1. 只看數據權限

  首先明白jeecg數據列表加載邏輯,即xxxxConroller.do?list&id=xxxx,跳轉到jsp頁面,

  然后再jsp頁面,通過異步方式加載數據xxxxController.do?datagrid進行數據加載。

 

1)首先添加一個數據權限類型的菜單,注意菜單類型為“權限類型”,入下圖,“商品類別權限”做為“商品列表”的權限菜單。注意圈住的地方

 

2)設置權限菜單的數據規則

如果是自定義sql,相當於就是在數據后追加條件,是以原生sql方式追加的,

 

userName='#{sysUserCode}'

3)設置角色數據權限

6.jeecg上傳到服務器,很多配置文件找不到

原因用了nginx,最終的請求是通過nginx去訪問的tomcat。而nginx訪問tomcat用的是127.0.0.1,所以資源路徑中

+request.getServerName()獲取的是127.0.0.1

 

 

/**
     * 獲取當前域名路徑
     * @param request
     * @return
     */
    public static String getBasePath() {
        HttpServletRequest request = ContextHolderUtils.getRequest();
        String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath();
        return basePath;
    }

 

 

 

例如我的配置如下,proxy_set_header Host $host; 表示不換請求頭

 

location /gdsk {
proxy_pass http://127.0.0.1:8082;
proxy_set_header Host $host; 
}

 7.socket 反向代理設置

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        # location / {
        #    root   html;
        #    index  index.html index.htm;
        #}
      location /wss {
        proxy_pass http://127.0.0.1:8081;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header X-Real-IP $remote_addr;
      }

        location /gdsk {
            proxy_pass http://127.0.0.1:8082;
            proxy_set_header Host $host;
        }   
    
        
        location /nginx_status {  
            allow 127.0.0.1;
            deny all;
            stub_status on;  
            access_log  off;  
        }  
    }

前端頁面websocket 連接;

ws = new WebSocket("ws://{ip}/wss");

 測試工具http://coolaf.com/tool/chattest

7.jeecg沒有字典

package com.jeecg.util;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.MapListHandler;
import org.jeecgframework.web.system.pojo.base.TSType;

public class GeecgUtil {
    public static TSType getDict(String groupName,String typecode) {
        String sql="select t.*  from t_s_type t\n" + 
                "        inner join t_s_typegroup tg on tg.ID=t.typegroupid\n" + 
                "        where tg.typegroupcode='"+groupName+"' and t.typecode='"+typecode+"'";
        QueryRunner qr =new QueryRunner(JDBCUtils.getDataSource());
        try {
            List<Map<String, Object>> query = qr.query(sql, new MapListHandler());
            if(query.size()>0) {
                TSType ts=new TSType();
                ts.setId(query.get(0).get("id").toString());
                ts.setOrderNum(Integer.valueOf(query.get(0).get("order_num").toString()));
                ts.setTypecode(query.get(0).get("typecode").toString());
                ts.setTypename(query.get(0).get("typename").toString());
                return ts;
            }
        } catch (SQLException e) {
            e.printStackTrace();
            
        }
        return null;
    }
    public static List<TSType> getDictList(String groupName) {
        String sql="select t.*  from t_s_type t\n" + 
                "        inner join t_s_typegroup tg on tg.ID=t.typegroupid\n" + 
                "        where tg.typegroupcode='"+groupName+"'";
        QueryRunner qr =new QueryRunner(JDBCUtils.getDataSource());
        try {
            List<Map<String, Object>> query = qr.query(sql, new MapListHandler());
            List<TSType> tsList =new ArrayList<TSType>();
            if(query.size()>0) {
                TSType ts=new TSType();
                ts.setId(query.get(0).get("id").toString());
                ts.setOrderNum(Integer.valueOf(query.get(0).get("order_num").toString()));
                ts.setTypecode(query.get(0).get("typecode").toString());
                ts.setTypename(query.get(0).get("typename").toString());
                tsList.add(ts);
            }
            return tsList;
        } catch (SQLException e) {
            e.printStackTrace();
            
        }
        return null;
    }

}

 8.Ambiguous handler methods mapped for HTTP path 

說明下報錯大致原因。我的一個控制器中,有兩個方法下面有貼出來。我去更新一條數據的時候,准備執行toUpdate。但是請求進入控制器中,找不到具體的請求(應該是jeecg解析請求有bug),因為分不清楚,導致該錯誤。我吧沖突的放到另外一個控制解決

Ambiguous handler methods mapped for HTTP path 'http://www.laotinghuagong.com/gdsk/gpsElectricFenceController.do': 
{public org.jeecgframework.core.common.model.json.AjaxJson com.jeecg.gps.controller.GpsElectricFenceController.doUpdate(com.jeecg.gps.entity.GpsElectricFenceEntity,
javax.servlet.http.HttpServletRequest), public org.jeecgframework.core.common.model.json.AjaxJson com.jeecg.gps.controller.GpsElectricFenceController.goUpdate(java.lang.String,javax.servlet.http.HttpServletRequest)}
/**
     * 更新電子圍欄
     * 
     * @param ids
     * @return
     */
    @RequestMapping(params = "doUpdate")
    @ResponseBody
    public AjaxJson doUpdate(GpsElectricFenceEntity gpsElectricFence, HttpServletRequest request) {
        String message = null;
        AjaxJson j = new AjaxJson();
        message = "電子圍欄更新成功";
        GpsElectricFenceEntity t = gpsElectricFenceService.get(GpsElectricFenceEntity.class, gpsElectricFence.getId());
        try {
            MyBeanUtils.copyBeanNotNull2Bean(gpsElectricFence, t);
            gpsElectricFenceService.saveOrUpdate(t);
            systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
        } catch (Exception e) {
            e.printStackTrace();
            message = "電子圍欄更新失敗";
            throw new BusinessException(e.getMessage());
        }
        j.setMsg(message);
        return j;
    }
/**
     * 單個電子圍欄
     * 
     * @return
     */
    @RequestMapping(params = "scope")
    @ResponseBody
    public AjaxJson scope(String id, HttpServletRequest req) {
        QueryRunner  qr = new QueryRunner(JDBCUtils.getDataSource());
        String sql="select scope from gps_electric_fence where id='"+id+"'";
        try {
            List<Map<String, Object>> query = qr.query( sql, new MapListHandler());
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            JSONObject data = new JSONObject();
            data.put("stat", 1);
            data.put("mess", "singleScope");
            data.put("data", query.get(0).get("scope").toString());
            
            //JSONObject parseObject = JSON.parseObject(query.get(0).get("scope").toString());
            OnlineChatServerPool.sendMessage(data.toString());
        } catch (SQLException e) {
            e.printStackTrace();
            
        }
        AjaxJson j =new AjaxJson();
        j.setSuccess(true);
        j.setMsg("電子圍欄發送到客戶端");
        j.setCode("200");
        return j;
    }

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM