问答详情
源自:3-11 用户模型管理--用户注册功能实现02

跨域成功之后,debug已经从session得到值了,但是注册失败,信息如下

### Error updating database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

### The error may involve com.miaoshaproject.dao.UserPasswordDOMapper.insertSelective-Inline

### The error occurred while setting parameters

### SQL: insert into user_password

### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1] with root cause


com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1


提问者:dpq592 2021-03-06 16:54

个回答

  • qq_慕仙6520305
    2021-07-04 16:59:26

    UserDOMapper.xml

    id="insertSelective" 中添加
    keyProperty="id" useGeneratedKeys="true"
    UserServiceImpl中
    //实现model转成do(dataobject)方法
    UserDO userDO=convertFormModel(userModel);
    userDOMapper.insertSelective(userDO);
    后添加
    userModel.setId(userDO.getId());


  • 慕姐6185899
    2021-03-07 02:57:10

    insertByPrimaryKey中加这个没:

    keyProperty="id" useGeneratedKeys="true"