批量删除以及将String数组转换成Integer数组的奇淫技巧

首先在pom.xml文件添加依赖:

<!-- bean工具 -->
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.8.3</version>
</dependency>

mapper.xml:

<delete id="deleteFormTemplate" parameterType="com.activiti.entity.TblAssActivitiFormTemplate">
delete from
asura.tbl_ass_activiti_form_template
where
aft_id in
<foreach item="aftIdArray" collection="array" open="(" separator=","
close=")">
#{aftIdArray}
</foreach>
</delete>

mapper.java:

Integer deleteFormTemplate(Integer[] aftId);

serviceImpl:

    @Override
public Integer deleteFormTemplate(HttpServletRequest request) {
String[] aftIdStringArray = request.getParameter("aftIdList").split(",");
//将String数组转成Integer数组
Integer[] aftIdArray = (Integer[])ConvertUtils.convert(aftIdStringArray, Integer.class);
Integer status = formTemplateMapper.deleteFormTemplate(aftIdArray);
return status;
}

controller.java:

Integer status = formTemplateService.deleteFormTemplate(request);
上一篇:Liunx系统升级自带的Python版本


下一篇:python接口测试(post,get)-传参(data和json之间的区别)