<mapper namespace="com.example.YourMapper"> <insert id="batchInsertOrUpdate" parameterType="java.util.List"> <foreach collection="list" item="item" separator=";"> <if test="item.id != null"> <!-- 判断ID是否存在 --> SELECT COUNT(*) FROM your_table WHERE id = #{item.id} </if> <choose> <when test="_parameter[0] > 0"> <!-- 更新操作 --> UPDATE your_table SET column1 = #{item.column1}, column2 = #{item.column2} WHERE id = #{item.id} </when> <otherwise> <!-- 插入操作 --> INSERT INTO your_table (id, column1, column2) VALUES (#{item.id}, #{item.column1}, #{item.column2}) </otherwise> </choose> </foreach> </insert> </mapper>和mybatis-plus的saveOrUpdateBatch性能比较及如何选用,注:实体对象ID属于type = IdType.INPUT非自增

时间: 2023-12-09 22:06:18 AIGC 浏览: 321
`<insert>`标签方式和MyBatis-Plus的`saveOrUpdateBatch`方法是两种不同的方式来实现大批量数据操作。下面是它们的性能比较和如何选择的建议: 1. `<insert>`标签方式: - 性能比较:使用`<insert>`标签进行大批量数据操作时,会根据每个数据的ID是否存在执行对应的更新或插入操作。这种方式对于数据量较小的情况下性能较好,因为它会逐条执行SQL语句。但是对于大批量数据操作来说,可能会有较多的数据库交互,性能可能较低。 - 选择建议:如果您的数据量不是特别大,并且对性能要求不高,可以考虑使用`<insert>`标签方式。 2. `saveOrUpdateBatch`方法: - 性能比较:`saveOrUpdateBatch`是MyBatis-Plus提供的方法,它能够根据实体对象的ID自动判断执行插入或更新操作。这种方式可以减少数据库交互次数,提高性能,尤其在处理大批量数据时效果更好。 - 选择建议:如果您的数据量较大,并且对性能要求较高,推荐使用`saveOrUpdateBatch`方法。 根据您提供的注释信息,实体对象ID属于`IdType.INPUT`非自增类型。在这种情况下,使用`<insert>`标签方式可能更适合,因为您需要在插入操作中显式指定ID的值。 综上所述,如果您的数据量较小且对性能要求不高,可以选择使用`<insert>`标签方式。如果您的数据量较大且对性能有较高的要求,并且实体对象ID属于`IdType.INPUT`非自增类型,可以考虑使用MyBatis-Plus的`saveOrUpdateBatch`方法。根据具体情况选择适合您的方式。
阅读全文

相关推荐

<insert id="insertListSelective" parameterType="java.util.List"> INSERT INTO art_customer_leads_pool <trim prefix="(" suffix=")" suffixOverrides=","> <if test="id != null">id,</if> <if test="activityId != null">activity_id,</if> <if test="activityName != null">activity_name,</if> <if test="comCode != null">com_code,</if> <if test="comName != null">com_name,</if> <if test="customerName != null">customer_name,</if> <if test="licenseNo != null">license_no,</if> <if test="expiryMonth != null">expiry_month,</if> <if test="mobile != null">mobile,</if> <if test="referrerStaffNo != null">referrer_staff_no,</if> <if test="referrerType != null">referrer_type,</if> <if test="status != null">status,</if> <if test="source != null">source,</if> <if test="leadInboundTime != null">lead_inbound_time,</if> <if test="createTime != null">create_time,</if> <if test="updateTime != null">update_time,</if> </trim> VALUES <foreach collection="item" index="index" item="item" separator=","> <trim prefix="(" suffix=")" suffixOverrides=","> <if test="item.id != null">#{item.id, jdbcType=BIGINT},</if> <if test="item.activityId != null">#{item.activityId, jdbcType=VARCHAR},</if> <if test="item.activityName != null">#{item.activityName, jdbcType=VARCHAR},</if> <if test="item.comCode != null">#{item.comCode, jdbcType=VARCHAR},</if> <if test="item.comName != null">#{item.comName, jdbcType=VARCHAR},</if> <if test="item.customerName != null">#{item.customerName, jdbcType=VARCHAR},</if> <if test="item.licenseNo != null">#{item.licenseNo, jdbcType=VARCHAR},</if> <if test="item.expiryMonth != null">#{item.expiryMonth, jdbcType=DATE},</if> <if test="item.mobile != null">#{item.mobile, jdbcType=VARCHAR},</if> <if test="item.referrerStaffNo != null">#{item.referrerStaffNo, jdbcType=VARCHAR},</if> <if test="item.referrerType != null">#{item.referrerType, jdbcType=VARCHAR},</if> <if test="item.status != null">#{item.status, jdbcType=SMALLINT},</if> <if test="item.source != null">#{item.source, jdbcType=VARCHAR},</if> <if test="item.leadInboundTime != null">#{item.leadInboundTime, jdbcType=DATE},</if> <if test="item.createTime != null">#{item.createTime, jdbcType=DATE},</if> <if test="item.updateTime != null">#{item.updateTime, jdbcType=DATE},</if> </trim> </foreach> </insert> public interface ArtCustomerLeadsPoolExtMapper { int insertListSelective(@Param("item") List<ArtCustomerLeadsPool> record); }我这个那里写错了

<?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="com.ruoyi.test.mapper.BatchsMapper"> <resultMap type="com.ruoyi.test.domain.Batchs" id="BatchsResult"> <result property="batchId" column="batch_id"/> <result property="batchName" column="batch_name"/> <result property="modelId" column="model_id"/> <result property="productionId" column="production_id"/> <result property="bomId" column="bom_id"/> <result property="amounts" column="amounts"/> <result property="completeAmount" column="complete_amount"/> <result property="createTime" column="create_time"/> <result property="updateTime" column="update_time"/> <result property="updateBy" column="update_by"/> <result property="createBy" column="create_by"/> <result property="delFlag" column="del_flag"/> <result property="factoryId" column="factory_id"/> </resultMap> <resultMap id="BatchsVo" type="com.ruoyi.test.domain.vo.BatchsVo"> <result property="total" column="total"/> <result property="bomId" column="bom_id"/> </resultMap> <resultMap id="Seq" type="com.ruoyi.test.domain.DailySequence"> <result property="date" column="date"/> <result property="currentSeq" column="current_seq"/> </resultMap> <sql id="selectBatchsVo"> select batch_id, batch_name, model_id, production_id, bom_id, amounts, complete_amount, create_time, update_time, update_by, create_by, del_flag, factory_id from batchs </sql> <select id="selectBatchsList" parameterType="com.ruoyi.test.domain.Batchs" resultMap="BatchsResult"> <include refid="selectBatchsVo"/> <where> <if test="batchId != null and batchId != ''">and batch_id = #{batchId}</if> <if test="batchName != null and batchName != ''">and batch_name like concat('%', #{batchName}, '%')</if> <if test="productionId != null and productionId != ''">and production_id = #{productionId}</if> <if test="bomId != null and bomId != ''">and bom_id = #{bomId}</if> <if test="factoryId != null and factoryId != ''">and factory_id = #{factoryId}</if> </where> order by create_time desc </select> <select id="selectBatchsByBatchId" parameterType="String" resultMap="BatchsResult"> <include refid="selectBatchsVo"/> where batch_id = #{batchId} </select> <insert id="insertBatchs" parameterType="com.ruoyi.test.domain.Batchs"> insert into batchs <trim prefix="(" suffix=")" suffixOverrides=","> <if test="batchId != null">batch_id,</if> <if test="batchName != null">batch_name,</if> <if test="modelId != null and modelId != ''">model_id,</if> <if test="productionId != null and productionId != ''">production_id,</if> <if test="bomId != null and bomId != ''">bom_id,</if> <if test="amounts != null">amounts,</if> <if test="completeAmount != null">complete_amount,</if> <if test="createTime != null">create_time,</if> <if test="updateTime != null">update_time,</if> <if test="updateBy != null">update_by,</if> <if test="createBy != null">create_by,</if> <if test="delFlag != null">del_flag,</if> <if test="factoryId != null">factory_id,</if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="batchId != null">#{batchId},</if> <if test="batchName != null">#{batchName},</if> <if test="modelId != null and modelId != ''">#{modelId},</if> <if test="productionId != null and productionId != ''">#{productionId},</if> <if test="bomId != null and bomId != ''">#{bomId},</if> <if test="amounts != null">#{amounts},</if> <if test="completeAmount != null">#{completeAmount},</if> <if test="createTime != null">#{createTime},</if> <if test="updateTime != null">#{updateTime},</if> <if test="updateBy != null">#{updateBy},</if> <if test="createBy != null">#{createBy},</if> <if test="delFlag != null">#{delFlag},</if> <if test="factoryId != null">#{factoryId},</if> </trim> </insert> <update id="updateBatchs" parameterType="com.ruoyi.test.domain.Batchs"> update batchs <trim prefix="SET" suffixOverrides=","> <if test="batchName != null">batch_name = #{batchName},</if> <if test="modelId != null and modelId != ''">model_id = #{modelId},</if> <if test="productionId != null and productionId != ''">production_id = #{productionId},</if> <if test="bomId != null and bomId != ''">bom_id = #{bomId},</if> <if test="amounts != null">amounts = #{amounts},</if> <if test="completeAmount != null">complete_amount = #{completeAmount},</if> <if test="createTime != null">create_time = #{createTime},</if> <if test="updateTime != null">update_time = #{updateTime},</if> <if test="updateBy != null">update_by = #{updateBy},</if> <if test="createBy != null">create_by = #{createBy},</if> <if test="delFlag != null">del_flag = #{delFlag},</if> <if test="factoryId != null">factory_id = #{factoryId},</if> </trim> where batch_id = #{batchId} </update> <delete id="deleteBatchsByBatchId" parameterType="String"> delete from batchs where batch_id = #{batchId} </delete> <delete id="deleteBatchsByBatchIds" parameterType="String"> delete from batchs where batch_id in <foreach item="batchId" collection="array" open="(" separator="," close=")"> #{batchId} </foreach> </delete> <select id="selectMaxSeqByDate" parameterType="String" resultMap="Seq"> select * from daily_sequence where date = #{date} </select> <update id="updateMaxSeqByDate"> update daily_sequence set current_seq = #{currentSeq} where date = #{date} </update> <insert id="insertMaxSeqByDate"> insert into daily_sequence (date, current_seq) values (#{date}, #{currentSeq}) </insert> <select id="selectCountByBomIds" resultMap="BatchsVo"> SELECT SUM(complete_amount) as total,bom_id from batchs WHERE bom_id in <foreach item="id" collection="list" open="(" separator="," close=")"> #{id} </foreach> and del_flag = 0 GROUP BY bom_id </select> <insert id="batchInsert" parameterType="java.util.List"> insert into batchs ( batch_id, batch_name, model_id, production_id, bom_id, amounts, complete_amount, create_time, update_time, update_by, create_by, factory_id ) values <foreach collection="list" item="item" index="index" separator=","> ( #{item.batchId}, #{item.batchName}, #{item.modelId}, #{item.productionId}, #{item.bomId}, #{item.amounts}, #{item.completeAmount}, #{item.createTime}, #{item.updateTime}, #{item.updateBy}, #{item.createBy}, #{item.factoryId} ) </foreach> </insert> <update id="batchUpdate" parameterType="java.util.List"> UPDATE batchs SET <if test="list != null and !list.isEmpty()"> batch_name = CASE batch_id <foreach collection="list" item="item"> <if test="item.batchName != null"> WHEN #{item.batchId} THEN #{item.batchName} </if> </foreach> ELSE batch_name END, </if> <if test="list != null and !list.isEmpty()"> model_id = CASE batch_id <foreach collection="list" item="item"> <if test="item.modelId != null and item.modelId != ''"> WHEN #{item.batchId} THEN #{item.modelId} </if> </foreach> ELSE model_id END, </if> <if test="list != null and !list.isEmpty()"> production_id = CASE batch_id <foreach collection="list" item="item"> <if test="item.productionId != null and item.productionId != ''"> WHEN #{item.batchId} THEN #{item.productionId} </if> </foreach> ELSE production_id END, </if> <if test="list != null and !list.isEmpty()"> bom_id = CASE batch_id <foreach collection="list" item="item"> <if test="item.bomId != null and item.bomId != ''"> WHEN #{item.batchId} THEN #{item.bomId} </if> </foreach> ELSE bom_id END, </if> <if test="list != null and !list.isEmpty()"> amounts = CASE batch_id <foreach collection="list" item="item"> <if test="item.amounts != null"> WHEN #{item.batchId} THEN #{item.amounts} </if> </foreach> ELSE amounts END, </if> <if test="list != null and !list.isEmpty()"> complete_amount = CASE batch_id <foreach collection="list" item="item"> <if test="item.completeAmount != null"> WHEN #{item.batchId} THEN #{item.completeAmount} </if> </foreach> ELSE complete_amount END, </if> <if test="list != null and !list.isEmpty()"> update_time = CASE batch_id <foreach collection="list" item="item"> <if test="item.updateTime != null"> WHEN #{item.batchId} THEN #{item.updateTime} </if> </foreach> ELSE update_time END, </if> <if test="list != null and !list.isEmpty()"> update_by = CASE batch_id <foreach collection="list" item="item"> <if test="item.updateBy != null"> WHEN #{item.batchId} THEN #{item.updateBy} </if> </foreach> ELSE update_by END, </if> <if test="list != null and !list.isEmpty()"> factory_id = CASE batch_id <foreach collection="list" item="item"> <if test="item.factoryId != null"> WHEN #{item.batchId} THEN #{item.factoryId} </if> </foreach> ELSE factory_id END </if> WHERE batch_id IN <foreach collection="list" item="item" open="(" separator="," close=")"> #{item.batchId} </foreach> </update> <update id="delByProductionId" parameterType="String"> update batchs set del_flag = 1 where production_id = #{productionId} </update> <update id="delByBomId" parameterType="String"> update batchs set del_flag = 1 where bom_id = #{productionId} </update> </mapper>改为根据batchName更新

<?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="com.example.exam.mapper.BackupRecordMapper"> <sql id="Base_Column_List"> id, user_id, backup_path, backup_time, status, remark </sql> <select id="selectById" resultType="com.example.exam.entity.BackupRecord"> SELECT <include refid="Base_Column_List"/> FROM t_backup_record WHERE id = #{id} </select> <select id="selectByUserId" resultType="com.example.exam.entity.BackupRecord"> SELECT <include refid="Base_Column_List"/> FROM t_backup_record WHERE user_id = #{userId} ORDER BY backup_time DESC </select> <insert id="insert" parameterType="com.example.exam.entity.BackupRecord" useGeneratedKeys="true" keyProperty="id"> INSERT INTO t_backup_record (user_id, backup_path, backup_time, status, remark) VALUES (#{userId}, #{backupPath}, #{backupTime}, #{status}, #{remark}) </insert> <update id="updateById" parameterType="com.example.exam.entity.BackupRecord"> UPDATE t_backup_record SET user_id = #{userId}, backup_path = #{backupPath}, backup_time = #{backupTime}, status = #{status}, remark = #{remark} WHERE id = #{id} </update> <delete id="deleteById" parameterType="java.lang.Long"> DELETE FROM t_backup_record WHERE id = #{id} </delete> <select id="selectPageByUserId" resultType="com.example.exam.entity.BackupRecord"> SELECT <include refid="Base_Column_List"/> FROM t_backup_record WHERE user_id = #{userId} ORDER BY backup_time DESC </select> </mapper>

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]这是报错

<%@ page contentType="text/html;charset=UTF-8" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <html> <head> <title>班级列表</title> </head> <body> 班级列表 添加班级 班级名称 操作 <c:forEach var="cls" items="${classist}"> ${cls.cname} (ID: ${cls.cid}) 查看成绩 查看学生 </c:forEach> </body> </html><%@ page contentType="text/html;charset=UTF-8" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <html> <head> <title>班级列表</title> </head> <body> 班级列表 年级 操作 <c:forEach var="gls" items="${gradeList}"> ${gls.term} (ID: ${gls.gid}) 查看第一学生成绩 查看第二学生成绩 查看第三学生成绩 查看第四学生成绩 s </c:forEach> </body> </html>package com.buka.controller; import com.buka.po.Grade; import com.buka.po.Student; import com.buka.service.GradeService; import com.buka.service.StuService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; import java.util.List; @Controller public class GradeController { @Autowired GradeService gradeService; @Autowired StuService stuService; @RequestMapping("/addGrade") public ModelAndView addGrade(Grade grade,ModelAndView mv ){ gradeService.addGrade(grade); Integer sid = grade.getSid(); List<Student>studentList = gradeService.getallS(); if (studentList == null) { mv.setViewName("error.jsp"); mv.addObject("message", "找不到对应的学生"); return mv; } mv.addObject("stuList", studentList); mv.setViewName("Student.jsp"); return mv; } @RequestMapping("/ShowGrade") public ModelAndView showGrade(String term,ModelAndView mv ){ List<Grade> gradeList = gradeService.showGradeByTerm(term); mv.addObject("gradeList", gradeList); mv.setViewName("ShowGrade.jsp"); return mv; } } <?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="com.buka.dao.GradeDao"> <insert id="addGrade" parameterType="com.buka.po.Grade"> INSERT INTO grade (gid, term, sid, math, chinese, English) VALUES (#{gid}, #{term}, #{sid}, #{math}, #{chinese}, #{English}) </insert> <select id="selectGradeByTerm" parameterType="String" resultType="java.util.Map"> SELECT s.name , g.math , g.chinese , g.English , g.term FROM grade g INNER JOIN student s ON g.sid = s.sid WHERE g.term = #{term} ORDER BY s.name </select> </mapper><?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="com.buka.dao.GradeDao"> <insert id="addGrade" parameterType="com.buka.po.Grade"> INSERT INTO grade (gid, term, sid, math, chinese, English) VALUES (#{gid}, #{term}, #{sid}, #{math}, #{chinese}, #{English}) </insert> <select id="selectGradeByTerm" parameterType="String" resultType="java.util.Map"> SELECT s.name , g.math , g.chinese , g.English , g.term FROM grade g INNER JOIN student s ON g.sid = s.sid WHERE g.term = #{term} ORDER BY s.name </select> </mapper>package com.buka.service; import com.buka.dao.GradeDao; import com.buka.dao.Studao; import com.buka.po.Grade; import com.buka.po.Student; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; @Service public class GradeService { @Autowired GradeDao gradeDao; @Autowired Studao studao; public int addGrade(Grade grade){ return gradeDao.addGrade(grade); } public List<Student> getallS() { return studao.getallS(); } public List<Grade>showGradeByTerm(String term){ return gradeDao.showGradeByTerm(term); } }

<?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="cn.kmbeast.mapper.MessageMapper"> <insert id="batchSave"> INSERT INTO message (content,message_type,receiver_id,sender_id,is_read,content_id,create_time) VALUES <foreach collection="list" item="message" index="index" separator=","> (#{message.content}, #{message.messageType}, #{message.receiverId}, #{message.senderId}, #{message.isRead}, #{message.contentId}, #{message.createTime}) </foreach> </insert> <update id="update"> UPDATE message <set> <if test="isRead != null"> is_read = #{isRead}, </if> </set> WHERE receiver_id = #{userId} </update> <delete id="batchDelete" parameterType="list"> DELETE FROM message WHERE id IN <foreach collection="ids" item="id" open="(" separator="," close=")"> #{id} </foreach> </delete> <select id="query" resultMap="BaseResultMap"> SELECT m.*, u1.user_name AS receiver_name, u2.user_name AS sender_name, e.content AS evaluations_content FROM message m LEFT JOIN user u1 ON u1.id = m.receiver_id LEFT JOIN user u2 ON u2.id = m.sender_id LEFT JOIN evaluations e ON e.id = m.content_id <where> <if test="userId != null"> AND m.receiver_id = #{userId} </if> <if test="messageType != null"> AND m.message_type = #{messageType} </if> <if test="content != null and content != ''"> AND m.content LIKE concat('%',#{content},'%') </if> <if test="isRead != null"> AND m.is_read = #{isRead} </if> <if test="startTime != null and endTime != null"> AND m.create_time BETWEEN #{startTime} AND #{endTime} </if> </where> ORDER BY m.create_time DESC <if test="current != null and size != null"> LIMIT #{current},#{size} </if> </select> <select id="queryCount" resultType="integer"> SELECT COUNT(*) FROM message m <where> <if test="userId != null"> AND m.receiver_id = #{userId} </if> <if test="messageType != null"> AND m.message_type = #{messageType} </if> <if test="content != null and content != ''"> AND m.content LIKE concat('%',#{content},'%') </if> <if test="isRead != null"> AND m.is_read = #{isRead} </if> <if test="startTime != null and endTime != null"> AND m.create_time BETWEEN #{startTime} AND #{endTime} </if> </where> </select> <resultMap id="BaseResultMap" type="cn.kmbeast.pojo.vo.MessageVO"> <id column="id" property="id"/> <result column="content" property="content"/> <result column="message_type" property="messageType"/> <result column="receiver_id" property="receiverId"/> <result column="sender_id" property="senderId"/> <result column="is_read" property="isRead"/> <result column="content_id" property="contentId"/> <result column="create_time" property="createTime"/> <result column="sender_name" property="senderName"/> <result column="receiver_name" property="receiverName"/> <result column="evaluations_content" property="evaluationsContent"/> </resultMap> </mapper>

<%@ page contentType="text/html;charset=UTF-8" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <html> <head> <title>班级列表</title> </head> <body> 班级列表 添加班级 班级名称 操作 <c:forEach var="cls" items="${classist}"> ${cls.cname} (ID: ${cls.cid}) <button>查看成绩</button> 查看学生 </c:forEach> </body> </html><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%-- Created by IntelliJ IDEA. User: asus Date: 2025/9/14 Time: 21:19 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>Title</title> </head> <body> 学生列表 学生id 姓名 学号 班级id <c:forEach var="sls" items="${stuList}"> ${sls.sid} (ID: ${sls.sid}) ${sls.name} (name: ${sls.name}) ${sls.xuehao} (xuehao: ${sls.xuehao}) ${sls.cid} (cid: ${sls.cid}) 添加学生 修改学生 </c:forEach> </body> </html> package com.buka.controller; import com.buka.po.Student; import com.buka.service.StuService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; import java.util.List; @Controller public class StuController { @Autowired StuService stuService; @RequestMapping("/addStu") public ModelAndView addStu(Student student, ModelAndView mv) { stuService.addStu(student); mv.addObject("stu", student); mv.setViewName("Student.jsp"); return mv; } @RequestMapping("/Student") public ModelAndView selStu(Student student, ModelAndView mv) { List<Student> studentList=stuService.selStu(new Student()); mv.addObject("stuList", studentList); mv.setViewName("Student.jsp"); return mv; } } <?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="com.buka.dao.Studao"> <insert id="addStu" parameterType="com.buka.po.Student"> INSERT INTO student (sid, name, xuehao, cid) VALUES (#{sid}, #{name}, #{xuehao}, #{cid}) </insert> <update id="updateStu" parameterType="com.buka.po.Student"> </update> <select id="selStu" resultType="com.buka.po.Student"> SELECT s.sid, s.name, s.xuehao, s.cid FROM student s INNER JOIN class c ON s.cid = c.cid WHERE s.cid = #{cid} </select> </mapper>前面的班级部分已经完成,我想实现通过获取班级id查找班级里的人并呈现在Student.jsp

最新推荐

recommend-type

不同图片1234568

不同图片1234568
recommend-type

RaspberryMatic与Docker整合:CCU2固件容器化操作指南

### Docker与CCU2固件整合 #### 知识点1:Docker容器技术 Docker是一种开源的容器化平台,它允许开发者将应用及其依赖打包到一个可移植的容器中,该容器可以在任何支持Docker的机器上运行。Docker容器和传统的虚拟机不同,它不需要完整的操作系统镜像,而是利用宿主机的操作系统内核,实现了轻量级的隔离,启动速度快,资源消耗低。 #### 知识点2:CCU2固件与OpenHAB CCU2(CCU代表Comet Control Unit)固件通常用在HomeMatic智能家居自动化系统中,它负责管理和控制HomeMatic的设备。CCU2运行的是一个基于Linux的自定义系统,专门优化用于与HomeMatic硬件和软件通信。当把CCU2固件用于Docker容器时,意味着你可以在任何支持Docker的设备上,通过容器化的方式部署和运行CCU2环境,从而支持HomeMatic设备的控制。 #### 知识点3:RaspberryMatic RaspberryMatic是为树莓派量身打造的一个项目,它允许用户在树莓派上运行CCU2固件。项目提供了一整套的HomeMatic体验,包括备份功能、Dutty-Cycle、LAN GW等。RaspberryMatic的一个显著优点是支持多种架构,包括x86_64/amd64、ARM和ARM64。 #### 知识点4:Docker容器部署脚本 "docker-ccu"项目提供了一套脚本,这些脚本能够自动化创建一个Docker容器来运行CCU2固件。通常这类脚本命名为`deploy.sh`,开发者或者最终用户可以通过运行这些脚本来快速部署和启动Docker容器,而无需手动配置和启动容器的每一个步骤。 #### 知识点5:数据备份与迁移 在使用Docker容器进行部署时,用户可能需要在不同环境下迁移数据或者保留原有数据。脚本中提到了数据保留的问题,如果用户之前使用的是其他方式部署,比如非Docker方式或者使用了特定的docker卷或者容器名称,那么在调用`deploy.sh`脚本部署时,需要对设置进行相应的调整,以保证数据的完整性。 #### 知识点6:仓库维护与开源社区 项目维护者提到了不再计划继续更新该存储库,并提出了将仓库设置为只读模式的想法。这在开源社区中是比较常见的情况,尤其是在维护者有新的兴趣点或者由于个人时间限制时。在此情况下,开源项目可以通过社区协作来继续维护,或者寻求其他维护者的接手。 #### 知识点7:Shell脚本编写 由于项目中提到了一个叫做`deploy.sh`的脚本文件,这说明脚本是用Shell语言编写的。Shell脚本非常适合于执行自动化任务,比如配置环境、启动服务、管理文件系统等,因此在自动化部署或系统管理中经常被使用。了解Shell脚本编写,对于自动化管理Docker容器等任务至关重要。 #### 知识点8:社区支持和反馈 项目维护者在描述中提到,如果在一个月内没有收到任何关于将官方CCU作为容器使用的反馈,将会把仓库设置为只读模式。这表明了开源社区中项目的发展很大程度上依赖于社区成员的反馈和支持。因此,了解如何与开源项目互动,提交问题、建议和补丁,是参与开源社区的重要途径。 #### 知识点9:固件概念与兼容性 CCU2固件特别设计用于某些特定硬件,但通过Docker化的方式,开发者可以跨平台运行CCU2固件,这增加了固件的兼容性。Docker的隔离性允许用户在一个通用的软件层面上运行原本可能受限于特定硬件的固件,从而扩展了固件的应用场景。 #### 知识点10:操作系统架构支持 项目支持包括x86_64/amd64、ARM和ARM64在内的多种架构,说明了Docker容器在不同硬件平台上的高度可移植性。这一特点使得开发者可以在各种硬件上部署相同的环境,简化了跨平台应用的开发和部署。 #### 结语 该文档提供了一个关于如何将特定固件整合入Docker容器的方案,并说明了项目维护者对于未来发展的规划。这些内容不仅对有志于尝试或扩展该项目的个人有指导意义,同时也展示了开源社区协作以及Docker技术在部署和管理复杂系统环境中的重要性和便利性。
recommend-type

手把手封装SDK:C#如何高效集成汉印D35BT打印功能

# 摘要 本文围绕C# SDK封装与汉印D35BT打印机集成的技术实践展开,系统阐述了SDK封装的理论基础、架构设计及面向对象设计原则的应用。文章分析了汉印D35BT打印机的通信协议与API调用方式,并详细介绍了在C#中实现蓝牙设备交互与数据发送的方法。通过核心打印功能的类封装、异步任务处理机制的设计,提升了SDK的易用性与扩展性。结合WinForm项目示例验证功能完整性后,进一步探讨了SDK的性能优化策略、测试方法及发布流程,构建了从设计、实现到部署的完整技术路径。 # 关键字 SDK封装;蓝牙通信;面向对象设计;异步打印;API调用;NuGet包发布 参考资源链接:[C#开
recommend-type

VM虚拟机ubuntu桥接主机无线网络

### 配置 VMware Ubuntu 桥接模式连接无线网络 在 VMware 中配置 Ubuntu 虚拟机通过桥接模式连接主机的无线网络,需要确保虚拟机与主机处于同一网络段,并能够通过主机的无线网卡直接访问外部网络。以下是详细的配置步骤: #### VMware 设置桥接模式 1. **以管理员权限运行 VMware**,进入 **编辑 > 虚拟网络编辑器**。 2. 在 **虚拟网络编辑器** 界面中,找到 **VMnet0(桥接模式)** 的设置部分。 3. 在 **“桥接到”** 的下拉菜单中,选择主机的无线网卡设备。 4. 勾选 **“自动设置桥接”** 选项,确保 VMwar
recommend-type

Ruby on Rails跳蚤市场应用开发详解

根据提供的文件信息,我们可以从中提炼出以下知识点: ### 标题知识点 - **freemarket_sample_72h** - 标题暗示这是一份关于名为“freemarket”的跳蚤市场应用程序的72小时开发样例或原型。 - 样例名称“freemarket_sample_72h”可能用于内部标识或者版本控制,表明该样本是在有限的时间内(即72小时内)完成的。 ### 描述知识点 - **网站结构** - 首页:应用程序的入口点,通常包含总体介绍和导航链接。 - 产品页面:展示产品的列表或者详细信息。 - 展览页:可能指专门展示某些特殊产品或促销产品的页面。 - 应用信息:关于应用程序的基本信息,如版本号、开发团队、联系方式等。 - 应用概述:对应用程序功能和目标用户群体的简介。 - **用户账户信息** - 测试账号:为开发者或测试者提供的虚拟用户账号信息,以便进行应用程序的内部测试。 - 购买者信息:提供了邮箱地址、密码以及购买卡信息,是进行交易和购买所必需的。 - 卖家信息:提供了卖家的邮箱地址和密码,用于登录卖家账户进行产品上架和管理。 - **功能列表** - 新用户注册:允许新用户创建账户。 - 登录功能:用户可以使用凭证登录应用程序。 - 产品列表功能:展示所有可购买的产品。 - 产品购买功能:用户可以购买产品,涉及到支付信息的处理。 - 产品类别注册和显示:允许用户查看不同的产品分类。 - 产品详细信息显示:展示每个产品的详细信息,如描述、价格等。 - 编辑和删除列出的产品:赋予管理员或卖家权利更新或移除产品信息。 - **开发环境** - Ruby 2.5.1:这是Ruby编程语言的一个版本。 - Ruby on Rails 5.4.2:这是一个使用Ruby语言编写的开源Web应用框架。 - MySQL 14.14:这是一个流行的开源关系型数据库管理系统。 - Github:一个用于代码托管和版本控制的平台。 - AWS:亚马逊提供的云服务平台,包括EC2(弹性计算云)和S3(简单存储服务)。 - Capistrano:是一个开源的自动化部署工具,常用于Ruby on Rails项目。 - **开发周期和工作时间** - 开发时间:约4周,说明了项目从开始到完成所需的时间。 - 每天平均工作时间:大约9小时,表明项目的紧凑和开发团队的努力。 - 开发系统人数:4,指出了参与该项目的开发人员数量。 - 敏捷类型:可能指的是一种开发过程,强调快速迭代和响应变化。 ### 标签知识点 - **Ruby** - 这个标签直接指向了Ruby编程语言,说明该应用程序是使用Ruby开发的。 ### 压缩包子文件的文件名称列表知识点 - **freemarket_sample_72h-master** - 这是源代码压缩包的文件名称,指示了一个版本控制中的主分支(master)。 通过这些信息,我们可以了解到该应用程序是一个在线跳蚤市场,它允许用户注册、登录、查看和购买产品,并且提供了产品管理功能。项目采用Ruby语言和Ruby on Rails框架开发,并使用了多种技术和平台,如MySQL数据库、Github、AWS云服务以及Capistrano部署工具。项目开发遵循敏捷开发原则,并在一个紧凑的时间表中完成。
recommend-type

【C#条码打印实战技巧】:汉印D35BT数据格式转换全攻略

# 摘要 本文围绕C#语言实现条码打印的技术方案展开,重点以汉印D35BT打印机为实践对象,系统性地讲解了条码打印中数据格式的基本原理与处理方法。文章分析了条码打印的数据流向、通信协议与命令集结构,探讨了在C#开发环境下实现数据格式转换、命令封装与容错机制的关键技术。通过完整的打印流程实现、性能优化策略以及常见问题排查方法的介绍,帮助开发者构建高效稳定的条码打印应用。同时,文章还展望了条码打印技术在多协议支持、云服务集成与企业级系统对接方面的拓展方向。 # 关键字 条码打印;数据格式;C#开发;通信协议;命令封装;容错机制 参考资源链接:[C#开发汉印D35BT条码打印机源代码
recommend-type

pikaqiu靶场搭建linux

在Linux系统上搭建名为“Pikachu”的靶场环境,主要涉及以下几个步骤: ### 下载并安装Pikachu靶场 首先,需要确保系统中已安装Git工具。如果尚未安装,可以通过以下命令安装Git: ```bash sudo yum install git ``` 接下来,使用Git从GitHub上克隆Pikachu靶场的源代码到本地: ```bash git clone https://github.com/zhuifengshaonianhanlu/pikachu.git ``` 完成下载后,将Pikachu靶场文件移动到Apache服务器的根目录下,以便于后续的Web访问:
recommend-type

jsTris: 探索俄罗斯方块的JavaScript实现

俄罗斯方块是一款经典的电子游戏,自1984年由苏联程序员阿列克谢·帕基特诺夫在计算机上首次开发以来,就以其简单而又富有挑战性的玩法吸引了世界各地的玩家。随着时间的发展,许多开发者开始尝试使用不同的编程语言和平台对俄罗斯方块进行重制或创新。本篇将详细介绍关于一个名为“jsTris”的俄罗斯方块游戏的JavaScript实现。 ### 1. JavaScript与Web游戏开发 JavaScript是一种广泛用于网页前端开发的脚本语言,它能够让网页拥有动态交互功能。自ECMAScript 5版本之后,JavaScript性能得到了显著的提升,使其逐渐成为开发Web游戏的理想选择。通过HTML5的Canvas API与JavaScript的结合,开发者可以创建出流畅、富有吸引力的图形界面,为用户带来良好的游戏体验。 ### 2.俄罗斯方块游戏机制 俄罗斯方块的基本玩法是玩家需要移动、旋转和放置一系列下落的方块,使它们在底部拼成完整的一行或多行,这样可以消除方块并获得分数。当方块堆积到屏幕顶部时,游戏结束。游戏难度会随着时间的推移而逐渐增加。 ### 3. jsTris项目概述 "jsTris"是俄罗斯方块的一个JavaScript版本,由一位不具名的开发者于2014年开发,并上传到了GitHub上进行开源。项目中包含了所有实现俄罗斯方块游戏逻辑的JavaScript代码,以及必要的HTML和CSS文件,用以构建游戏界面。 尽管作者自述代码“非常混乱”,而且表示自己没有回过头来清理过,这可能意味着对于初学者和后来的维护者来说,理解原始代码的结构和逻辑可能会有一定难度。不过,即使代码结构不佳,jsTris仍然可以作为一个学习的资源,开发者可以通过重构和优化来提升代码质量,同时也更好地理解游戏背后的逻辑。 ### 4. 音乐资源 在描述中提到了音乐来源,但并未给出具体的音乐文件信息。通常情况下,Web游戏会使用一些背景音乐和效果音来增强游戏体验。在jsTris项目中,音乐文件可能被嵌入到了项目中,或者通过外部链接引入。音乐的版权问题在此类开源项目中需要特别注意,开发者使用音乐时应确保拥有相应的使用权或音乐已经处于公共领域。 ### 5. 标签和文件结构 本项目的标签是"JavaScript",表明该项目完全是使用JavaScript进行开发的。关于"jsTris-master"这个文件名,它可能是项目中的主文件夹,包含了游戏的核心代码和资源文件。在一个典型的JavaScript项目结构中,可能包括以下部分: - HTML文件:定义游戏的结构和入口点。 - CSS文件:负责游戏的样式和视觉效果。 - JavaScript文件:包含游戏逻辑、控制和交互代码。 - 音频文件:用于游戏背景音乐和各种效果音。 - 图片文件:可能包括游戏中的图标、角色或背景。 ### 6. 开源与社区 该项目被上传到了GitHub,这是一个全球性的开源社区,允许开发者贡献代码,共同改进项目。在GitHub上,jsTris项目可能拥有自己的README文件,用于说明如何运行游戏、如何贡献代码或报告问题等。开源项目对于开发者来说是学习和实践编程技巧的宝贵资源,同时也可以通过社区获得帮助和反馈,从而改进项目。 ### 7. 清理与重构代码的重要性 提到jsTris的代码"非常混乱",对于任何类型的软件项目而言,可读性和可维护性都是极其重要的。混乱的代码会导致开发者难以理解,更不用说进行进一步的开发或优化。因此,对于jsTris或任何类似项目,代码重构是一个需要认真对待的过程。重构可以提高代码质量,降低维护成本,并可能修复一些潜在的错误。 ### 总结 jsTris项目作为一款使用JavaScript实现的俄罗斯方块游戏,向我们展示了如何利用Web技术进行游戏开发。虽然存在代码结构上的问题,但它无疑为有兴趣学习和改进的开发者提供了实践机会。通过深入分析和可能的代码重构,不仅可以提升jsTris项目的质量,也可以使开发者自己在JavaScript编程和游戏开发方面获得宝贵的经验。
recommend-type

从失败到稳定打印:汉印D35BT常见问题排查与解决方案大全

# 摘要 本文围绕汉印D35BT打印机的使用与故障排查展开系统研究,首先介绍其基本功能与典型应用场景,进而从打印质量、通信连接及任务处理等方面深入分析常见故障的成因,涵盖硬件适配、环境影响、数据通信及固件兼容性等多个维度。基于理论分析,本文进一步提出针对典型问题的实操解决方案,并探讨打印性能优化、固件升级及企业系统集成等高级应用策略。通过案例分析与实践经验总结,旨在提升设备运行稳定性与打印效率,为企业用户提供可靠的技术支持和运维指导。 # 关键字 汉印D35BT;打印质量;蓝牙通信;打印缓冲区;固件升级;数据格式适配 参考资源链接:[C#开发汉印D35BT条码打印机源代码及二次
recommend-type

point transformer v3安装

要安装 **Point Transformer V3** 深度学习模型,通常需要从其开源代码库中获取源代码并进行本地部署。目前,该模型的实现可能托管在 GitHub 或类似的代码平台上。以下是安装和部署的一般步骤: ### 1. 环境准备 确保系统中已安装以下工具和库: - **Python**(建议 3.8 或更高版本) - **PyTorch**(建议版本 1.10 或更高) - **CUDA Toolkit**(与 PyTorch 兼容的版本) - **NVIDIA GPU驱动** - **编译工具链**(如 `ninja`、`CMake` 等) 安装 PyTorch 的示例命令