2 cherishjia cherishjia 于 2014.08.17 17:16 提问

修改文章信息 数据库没有任何更新
jsp

想对写好的文章进行修改 但是修改后没有任何变化。

private void modifyArticle(HttpServletRequest request,
        HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    response.setContentType("text/html;charset=utf-8");
    HttpSession session=request.getSession();
    ArticleBean articleBean=new ArticleBean();
    ArticleDao articleDao=new ArticleDao();

    /*String strId=request.getParameter("id");
    int id = Integer.parseInt(strId);*/
    String title=request.getParameter("title");
    String content=request.getParameter("content");
    Date cur=new Date(new java.util.Date().getTime());
    String time=cur.toLocaleString();

    //articleBean.setArt_id(id);
    articleBean.setArt_title(title);
    articleBean.setArt_time(time);
    articleBean.setArt_content(content);

    try {
        articleDao.operationArticle("modify", articleBean);
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    request.getRequestDispatcher("manage.jsp").forward(request, response);

}

Dao:

if(oper.equals("modify")){
        sql="update article set art_title='"+single.getArt_title()+"',art_content='"+single.getArt_content()+"',art_time='"+single.getArt_time()+"' where art_id="+single.getArt_id();
    }

1个回答

shendixiong
shendixiong   2014.08.18 11:02

一般出现这样的情况:
1.请确认是否已添加相关事务配置?
2.SQL语句是否正确,是否报错?

Csdn user default icon
上传中...
上传图片
插入图片