📄 modifytreeaction.java
字号:
/**
*
*/
package test.tree;
import java.io.UnsupportedEncodingException;
import javax.servlet.http.*;
import org.apache.struts.action.*;
import org.hibernate.Session;
import org.hibernate.Transaction;
import cn.bway.common.BwayHibernateException;
import cn.bway.common.LoginConstants;
import cn.bway.common.WebConstant;
import cn.bway.common.action.BaseAction;
import cn.bway.common.dao.HibernateSessionFactory;
/**
* @author Kson
*
*/
public class ModifyTreeAction extends BaseAction {
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
* @throws UnsupportedEncodingException
* @throws Exception
*/
public ActionForward execute(ActionMapping mapping,
ActionForm form,HttpServletRequest request, HttpServletResponse response)
throws BwayHibernateException, UnsupportedEncodingException {
ActionErrors errors = new ActionErrors();
String returnStr = WebConstant.FORWARD_SUCCESS;
Session sess=null;
Transaction tx=null;
HttpSession session=request.getSession();
String staffid="";
// request.setCharacterEncoding("gb2312");
String id = request.getParameter("id");
String Modifymenufatherid = request.getParameter("Modifymenufatherid");
String Modifymenuid = request.getParameter("Modifymenuid");
String treename = request.getParameter("treename2");
try {
sess=HibernateSessionFactory.currentSession();
tx=sess.beginTransaction();
staffid=(String) session.getAttribute(LoginConstants.GLOBLE_STAFF_ID);
String sql = "update testtree set menuid ='"+Modifymenuid+"' " +
", munefatherid ='"+Modifymenufatherid+"' , menuname ='"+treename+"'" +
" where id = '"+id+"' and staffid='"+staffid+"' ";
log.info("update tree sql: "+sql);
sess.connection().createStatement().executeUpdate(sql);
returnStr=WebConstant.FORWARD_SUCCESS;
request.setAttribute(WebConstant.RETURN_Message,"修改成功!");
tx.commit();
} catch (Exception e) {
returnStr=WebConstant.FORWARD_FAIL;
errors.add(ActionErrors.GLOBAL_ERROR,new ActionError("edu.system.excption",e.getMessage()));
this.saveErrors(request,errors);
tx.rollback();
e.printStackTrace();
}finally{
HibernateSessionFactory.closeSession();
}
return mapping.findForward(returnStr);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -