51代码网ORACLEMYSQLSQL SERVER其它数据库java/jspasp/asp.netC/C++/VC++APP应用其它语言服务器应用
您现在的位置: 51代码网 >> java >> 文章正文

Request processing failed; nested exception is org.springframework

更新时间:2014-8-15:  来源:51代码网

@RequestMapping(value = "/addgoods.jspx", method = RequestMethod.POST)
    public String stockin(GoodsInfo goods) {
        boolean flag =  miShopService.addgoods(goods);
        return null;
    }


将页面数据封装到GoodsInfo实体,然后插入数据库
INSERT INTO mishop.goods (NAME,CODE) VALUES (?,?)

报错:
HTTP Status 500 - Request processing failed; nested exception is org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL [INSERT INTO mishop.goods (NAME,CODE) VALUES (?,?)]; Data truncation: Data too long for column 'code' at row 1; nested exception is com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'code' at row 1

数据库code字段的为varchar(100),页面接收的是数据是"0001",明显没有超长。GoodsInfo实体中code的类型也是String

页面编码格式为:
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

数据库和数据库表的编码格式都是UTF-8  utf8_general_ci,引擎为InnoDB.
没碰到过这种问题,提供下我的思路参考吧
1、System.out.println(goods.getCode())看看接参到底有没有问题
2、拿sql去数据库里执行看看有没有问题
3、再看看编码问题,是不是都统一编码了
4、以上都不行再来求助
我getCode()的时候,选择提示的方法,选错了,弄成getClass()了

  • 上一篇文章:
  • 下一篇文章: 没有了
  • 赞助商链接
    推荐文章
  • 此栏目下没有推荐文章
  • {
    设为首页 | 加入收藏 | 友情链接 | 网站地图 | 联系站长 |