public interface CrawDao {
public void saveNewNews(@Param("params")Map<String, String> params);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" " http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="us.codecraft.webmagic.dao.CrawDao">
<insert id="saveNewNews" parameterType="java.util.Map">
insert ignore into tb_news
<foreach collection="params.keys" item="key" open="(" close=")" separator="," >
${key}
</foreach>
values
<foreach collection="params.keys" item="key" open="(" close=")" separator=",">
#{params[${key}]}
</foreach>
</insert>
</mapper>