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);
        }
    }
    
    
  • 相关阅读:
    二级指针内存模型(二)
    Winserver-FailoverCluster验证异常
    IIS-This configuration section cannot be used at this path.
    SQL SERVER-Extendevent捕获堵塞
    SQL SERVER-Extendevent
    Powershell-加域脚本
    SQL SERVER-端口Port
    WinServer-SMTP服务
    Linux-开机启动程序
    SQL SERVER-修改服务器名称
  • 原文地址:https://www.cnblogs.com/lick468/p/10966132.html
Copyright © 2011-2022 走看看