thymeleaf テンプレートはサービスを動的に呼び出し、パラメータを動的に渡します。

thymeleaf テンプレートはサービスを動的に呼び出し、パラメータを動的に渡します。

フロントエンド

console.log([[${
    
    patientInfo}]]) // 调用此页面时,后端传递的参数 patientInfo

var dept = [[${
    
    @dict.getBySql('select t.target_value as dict_value, t.target_name as dict_label from hos_dict_compare t where hos_dict_type_code = ''01'' and t.hos_value = ''__${patientInfo.rykb}__''')}]];

console.log(dept);

例証します:

バックグラウンドで取得したデータ「__${}__」を結合、前後ともアンダースコア2つ
1. バックグラウンドにシングルクォーテーションを付ける場合は文字列

2. 一重引用符を使用しないと、数値 __${}__ がバックグラウンドに渡されます。

サービス

@Service("dict")
public class DictService
{
    
    
  
    @Autowired
    private ISysDictDataService dictDataService;

    /**
     * 根据表名查询自定义字典数据信息
     *
     * @param sql sql语句
     * @return 参数键值
     */
    public List<SysDictData> getBySql(String sql)
    {
    
    
        return dictDataService.selectCustomDictDataBySql(sql);
    }
}

コントローラ

 @RequestMapping(value = "/jumpToUpdateZkInfo/{id}",method = RequestMethod.GET)
    public String jumpToUpdateZkInfo(@PathVariable Long id,BasyAuditResult basyAuditResult,ModelMap mmap){
    
    
        AuditInfo patientInfo = auditInfoService.selectAuditInfoById(id);
        mmap.put("basyAuditResult",basyAuditResult);
        mmap.put("patientInfo",patientInfo);
        return "test";
    }

おすすめ

転載: blog.csdn.net/m0_55628494/article/details/127506947