Parameter 'xxx' not found. 5C

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'title' not found. Available parameters are [1, 0, param1, param2]
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371)
at com.sun.proxy.$Proxy24.update(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.update(SqlSessionTemplate.java:254)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:54)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
at com.sun.proxy.$Proxy32.updateItemsById(Unknown Source)
at com.taotao.service.impl.ItemServiceImpl.updateItems(ItemServiceImpl.java:109)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
这是异常,下面开始上代码,一个简单的更新操作.

Tbitem和继承类ItemCustom:
 public class ItemCustom extends TbItem{

}
 public class TbItem {
    private Long id;

    private String title;

    private String sellPoint;

    private Long price;

    private Integer num;

    private String barcode;

    private String image;

    private Long cid;

    private Byte status;

    private Date created;

    private Date updated;

        //省略get/set方法
UpdateMapper.xml
 <mapper namespace="com.taotao.mapper.UpdateMapper">
    <update id="updateItemsById" parameterType="com.taotao.wto.ItemCustom">

          UPDATE tb_item SET title = '#{title}',price = #{price},num = #{num} WHERE id = #{id} 

    </update>
</mapper>

mapper接口:

 public interface UpdateMapper {
    ItemCustom updateItemsById(Long id,ItemCustom itemCustom);
}

service层的代码:

    @Override
    public void updateItems(Long id, ItemCustom itemCustom) {
        updateMapper.updateItemsById(id, itemCustom);
    }

controller:

//更新商品,提交商品更新信息
    @RequestMapping("/editItemsSubmit")
    public String editItemsSubmit(Long id,ItemCustom itemCustom){
        itemService.updateItems(id, itemCustom);
        return "success";
    }

最后是editItems.jsp:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>修改商品信息</title>

</head>
<body> 
<!-- submit后,表单提交到此action路径 -->
<form id="itemForm" action="${pageContext.request.contextPath }/editItemsSubmit.action" method="post" enctype="multipart/form-data">
<input type="hidden" name="id" value="${itemCustom.id }"/>
修改商品信息:
<table width="100%" border=1>
<tr>
    <td>商品名称</td>
    <td><input type="text" name="title" value="${itemCustom.title }"/></td>
</tr>
<tr>
    <td>商品价格</td>
    <td><input type="text" name="price" value="${itemCustom.price }"/></td>
</tr>
<tr>
    <td>商品数量</td>
    <td><input type="text" name="num" value="${itemCustom.num}"/></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="提交"/>
</td>
</tr>
</table>

</form>
</body>

</html>

求帮忙看看问题在哪,谢谢。

5个回答

TbItem的属性直接做成public修饰

回调函数,错误,没有找到对应的实体字段值

参数没找到,或者是参数的名字不对,你检查下你的dao接口是不是没写对

尴尬,我自己找到错误了
图片说明

用mybatis还是要注意下xml文件中#{}和${}的区别的

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问