问题遇到的现象和发生背景
我是在写增删改查中的修改
在点击修改后,会将JSON转化为java,并获取其中的id使用update方法来完成修改。
假如修改功能完成后,我会让新增功能与修改共用一个表单,通过判断有无id传入。有id传入的是修改,没有的是新增。
但是,卡死在了第一步,请求高人解惑。。
问题相关代码,请勿粘贴截图
```bash
<---BrandMapper--->
@Update("UPDATE tb_brand SET brand_name=brandName,company_name =companyName,ordered =ordered,description =description,status =status WHERE id = #{id}")
void update(@Param("brand") Brand brand ,@Param("id") Integer id);
<----BrandServlet----->
public void update(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
BufferedReader br = req.getReader();
String params = br.readLine();
Brand brand = JSON.parseObject(params,Brand.class);
Integer id =(Integer) brand.getId();
brandService.update(brand,id);
resp.getWriter().write("success");
}
###### 运行结果及报错内容
```bash
Caused by: org.apache.ibatis.exceptions.PersistenceException:
Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'brandName' in 'field list'
The error may exist in com/itheima/mapper/BrandMapper.java (best guess)
The error may involve com.itheima.mapper.BrandMapper.update-Inline
The error occurred while setting parameters