慕粉4016800
2017-03-09 09:28
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
//设置编码
req.setCharacterEncoding("utf-8");
//接受页面的值
String command = req.getParameter("command");
String description = req.getParameter("description");
//向页面传值
req.setAttribute("command", command);
req.setAttribute("description", description);
MaintainService maintainService = new MaintainService();
//查询消息列表并传给页面
req.setAttribute("messageList", maintainService.updateOne(command, description));
//页面跳转
req.getRequestDispatcher("/List.action").forward(req, resp);
} public List<Message> updateOne(String command, String description){
MessageDao messageDao = new MessageDao();
return messageDao.updateOne(command, description);
} public List<Message> updateOne(String command, String description){
DBAccess dbAccess = new DBAccess();
List<Message> messageList = new ArrayList<Message>();
SqlSession sqlSession = null;
try {
sqlSession = dbAccess.getSqlSession();
Message message = new Message();
message.setCommand(command);
message.setDescription(description);
sqlSession.update("Message.updateone", message);
sqlSession.commit();
System.out.println("看看message是啥?"+message.getCommand());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally{
if(sqlSession != null){
sqlSession.close();
}
}
return messageList;
} <update id="updateone" parameterType="com.imooc.bean.Message">
update MESSAGE
set
COMMAND=#{command},DESCRIPTION=#{description}
where ID=#{id}
</update>有没有大神做了修改功能可以提供个参考呢?
没有id 你的message对象是new出来的 set了要update的属性 没有setId吧
where ID=#{id}
id的值没有
什么问题
通过自动回复机器人学Mybatis---基础版
107417 学习 · 831 问题
相似问题