@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.
求教大神这是怎么回事?求解决方法,叩谢。