zoukankan      html  css  js  c++  java
  • thymeleaf 直接调用后台Service

    前端thymeleaf

    <select name="sex" class="form-control m-b" th:with="type=${@dict.getType('sys_user_sex')}">
             <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
    </select>
    

    拼接后台获取的数据 '__${ }__', 前后都是两个下划线 ,加单引号往后台传的时候是字符串,不加单引号往后台传的是数字, __${ }__

    <input  class="form-control m-b" th:with="type=${@dict.getLabel('sys_user_sex','__${hrmResource.sex}__')}" th:value="${type}" >
                 
    

    <div class="m-b" th:with="type=${@dict.getLabel('sys_blood','__${hrmResource.bloodType}__')}">[[${type}]]</div>
    

    后台 Spring boot

    
    /**
     * html调用 thymeleaf 实现字典读取
     */
    @Service("dict")
    public class DictService
    {
        @Autowired
        private IDictDataService dictDataService;
    
        /**
         * 根据字典类型查询字典数据信息
         * 
         * @param dictType 字典类型
         * @return 参数键值
         */
        public List<DictData> getType(String dictType)
        {
            return dictDataService.selectDictDataByType(dictType);
        }
    
        /**
         * 根据字典类型和字典键值查询字典数据信息
         * 
         * @param dictType 字典类型
         * @param dictValue 字典键值
         * @return 字典标签
         */
        public String getLabel(String dictType, String dictValue)
        {
            return dictDataService.selectDictLabel(dictType, dictValue);
        }
    }
    
    
  • 相关阅读:
    NEO发行资产Token
    OSCP考试回顾
    Windows降权
    Mimikatz.ps1本地执行
    MS16-032提权正确方法
    一种通过HTTP传文件出网的姿势
    mac chromedriver error
    关于websocket 在生产环境中遇到的问题 及 解决办法
    how to install protobuff python
    Git 使用疑问
  • 原文地址:https://www.cnblogs.com/lick468/p/10966132.html
Copyright © 2011-2022 走看看