有没有大神做了修改功能可以提供个参考呢?
@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>
有没有大神做了修改功能可以提供个参考呢?