带参数的<#nested param> 的用法

本文介绍了一种使用宏定义来生成HTML页面的方法。通过定义宏指令和条件判断,可以灵活地控制页面内容的嵌套显示。该方法适用于需要动态生成HTML结构的场景。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

<#macro part var1 var2>
<#if var1=var2><#nested></#if>
</#macro>

<#macro page>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<#nested 'head'>
</head>
<body>
<#nested 'body'>
</body>
</html>
</#macro>

 

<@page ;p>
<@part 'head' p>
<style>
</style>
</@>
<@part 'body' p>
<div></div>
</@>
/@page

生成

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style></style>
</head>
<body>
<div></div>
</body>
</html>

 

public int insertDeptList(List<Map<String,String>> deptList);这是接口, <insert id="insertDeptList" parameterType="java.util.List"> INSERT INTO sys_dept ( <if test="deptList[0].parent_id != null">parent_id,</if> <if test="deptList[0].ancestors != null">ancestors,</if> <if test="deptList[0].dept_name != null">dept_name,</if> <if test="deptList[0].order_num != null">order_num,</if> <if test="deptList[0].leader != null">leader,</if> <if test="deptList[0].phone != null">phone,</if> <if test="deptList[0].email != null">email,</if> <if test="deptList[0].status != null">status,</if> <if test="deptList[0].del_flag != null">del_flag,</if> <if test="deptList[0].create_by != null">create_by,</if> create_time, <if test="deptList[0].update_by != null">update_by,</if> <if test="deptList[0].update_time != null">update_time,</if> <if test="deptList[0].org_index_code != null">org_index_code,</if> <if test="deptList[0].org_no != null">org_no,</if> <if test="deptList[0].org_path != null">org_path,</if> <if test="deptList[0].parent_org_index_code != null">parent_org_index_code,</if> <if test="deptList[0].parent_org_name != null">parent_org_name,</if> ) VALUES <foreach collection="deptList" item="item" separator=","> ( <if test="item.parent_id != null">#{item.parentId},</if> <if test="item.ancestors != null">#{item.ancestors},</if> <if test="item.dept_name != null">#{item.deptName},</if> <if test="item.order_num != null">#{item.orderNum},</if> <if test="item.leader != null">#{item.leader},</if> <if test="item.phone != null">#{item.phone},</if> <if test="item.email != null">#{item.email},</if> <if test="item.status != null">#{item.status},</if> <if test="item.del_flag != null">#{item.delFlag},</if> <if test="item.create_by != null">#{item.createBy},</if> sysdate(), <if test="item.update_by != null">#{item.updateBy},</if> <if test="item.update_time != null">#{item.updateTime},</if> <if test="item.org_index_code != null">#{item.orgIndexCode},</if> <if test="item.org_no != null">#{item.orgNo},</if> <if test="item.org_path != null">#{item.orgPath},</if> <if test="item.parent_org_index_code != null">#{item.parentOrgIndexCode},</if> <if test="item.parent_org_name != null">#{item.parentOrgName},</if> ) </foreach> </insert>这是代码,nested exception is org.apache.ibatis.binding.BindingException: Parameter 'deptList' not found. Available parameters are [arg0, collection, list]这是报错
最新发布
08-05
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值