公司中Java使用Freemarker动态脚本查询Sql的坑

xiaoxiao2021-02-28  78

这里只是记录一下,并不是通用的

1.<#if specedParam><#else>不可省略,由于会参考模板,

#--查询10条免费的数字教材--> <#switch switchName> <#case "QUERY_FREE"> <#if specedParam> 这里写请求参数 <#else> <#--查询10条免费的数字教材--> SELECT <#t> jcwx_ebooks.id, <#t> jcwx_ebooks.url, <#t> jcwx_ebooks.cover, <#t> jcwx_ebooks.title, <#t> jcwx_ebooks.catalog, <#t> jcwx_ebooks.price, <#t> jcwx_ebooks.introduction, <#t> jcwx_ebooks.likes, <#t> jcwx_ebooks.isfree, <#t> jcwx_ebooks.isbn, <#t> jcwx_ebooks.type, <#t> jcwx_ebooks.word_count, <#t> jcwx_ebooks.author, <#t> jcwx_ebooks.press, <#t> jcwx_ebooks.addtime, <#t> jcwx_ebooks.isdel, <#t> jcwx_ebooks.download_count, <#t> jcwx_ebooks.views_count <#t> FROM <#t> jcwx_ebooks <#t> WHERE <#t> 1=1 <#t> AND <#t> jcwx_ebooks.isfree = 0 <#t> ORDER BY <#t> jcwx_ebooks.addtime DESC <#t> </#if> <#default>

2.Sql语句中不可以使用Limit条件。

3.其它说明

1).<#t>代表合并空格

SELECT <#t> jcwx_ebooks.id

等同于

SELECT jcwx_ebooks.id
转载请注明原文地址: https://www.6miu.com/read-38287.html

最新回复(0)