成人无码视频,亚洲精品久久久久av无码,午夜精品久久久久久毛片,亚洲 中文字幕 日韩 无码

資訊專欄INFORMATION COLUMN

thymeleaf-extras-db 0.0.1發(fā)布,select標(biāo)簽加載數(shù)據(jù)的新姿勢

Raaabbit / 3642人閱讀

摘要:需要注意的是,標(biāo)簽的數(shù)據(jù),是從表和查詢的,需要建表。在頁面上,需要給標(biāo)簽添加屬性。

在寫thymeleaf頁面的時候,我為了偷懶,不想為每個select下拉列表框都寫一個接口,于是這個懶人jar誕生了。該jar的核心功能是直接通過thymeleaf頁面的自定義標(biāo)簽的屬性,直接運行sql并初始化select數(shù)據(jù)。

項目地址:
github
gitee

簡介

thymeleaf-extras-db是針對thymeleaf的擴展,主要是簡化前端select標(biāo)簽數(shù)據(jù)的獲取,讓select標(biāo)簽直接從數(shù)據(jù)庫加載數(shù)據(jù),而不需要多帶帶寫接口,支持緩存。

導(dǎo)入

    com.github.jeesun.thymeleaf.extras
    thymeleaf-extras-db
    0.0.1
使用教程

thymeleaf-extras-db目前支持兩種自定義標(biāo)簽t:dict和t:select,兩個標(biāo)簽僅一個屬性不同,其他屬性兩者都支持。t:dict和t:select都支持普通select標(biāo)簽屬性,也支持select2和easyui-combobox屬性。需要注意的是,t:dict標(biāo)簽的數(shù)據(jù),是從表t_dict_type和t_dict_type_group查詢的,需要建表mysql.sql。

在html頁面上,需要給html標(biāo)簽添加屬性xmlns:t="http://www.w3.org/1999/xhtml"。
使用示例:



easyui中使用方式:
1. 新建配置類

在Spring Boot中,使用thymeleaf-extras-db很簡單,先新建一個配置類:

@Configuration
public class CustomDialectConfig {
    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Autowired
    private CacheManager cacheManager;

    @Bean
    public DbDialect dbDialect(){
        //return new DbDialect(jdbcTemplate);
        return new DbDialect(jdbcTemplate, cacheManager);
    }
}
2. 配置緩存

請在application.yml中添加如下配置:

spring:
  cache:
    cache-names: listOptionCache

如果你使用的是ehcache,那么還需要在ehcache.xml中新增如下類似配置:


3. 標(biāo)簽屬性及含義
屬性 含義 是否必填 可選值 默認(rèn)值
id id
class class
name name
style style
order 排序方式
allow-empty 允許空值 true,false true
empty-message 空值顯示內(nèi)容  
cacheable 是否允許緩存 true,false true
data-live-search select2專有屬性 true,false
multiple select2專有屬性 multiple
data-options easyui-combobox專有屬性
dict_name (t:dict獨有)字典名稱,只能填t_dict_type_group的type_group_code字段的值
query (t:select獨有)屬性規(guī)則:表名,顯示的字段名,作為option的value的字段名

文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請注明本文地址:http://m.hztianpu.com/yun/72430.html

相關(guān)文章

發(fā)表評論

0條評論

閱讀需要支付1元查看
<