📄 sharefoldersaction.java
字号:
/**
*
*/
package test.folder;
import java.io.UnsupportedEncodingException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.hibernate.Session;
import org.hibernate.Transaction;
import cn.bway.common.BwayHibernateException;
import cn.bway.common.Util;
import cn.bway.common.WebConstant;
import cn.bway.common.action.BaseAction;
import cn.bway.common.dao.HibernateSessionFactory;
/**
* @author Kson
*
*/
public class ShareFoldersAction extends BaseAction {
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
* @throws UnsupportedEncodingException
* @throws SQLException
* @throws Exception
*/
public ActionForward execute(ActionMapping mapping,
ActionForm form,HttpServletRequest request, HttpServletResponse response)
throws BwayHibernateException, UnsupportedEncodingException, SQLException {
ActionErrors errors = new ActionErrors();
String returnStr = WebConstant.FORWARD_SUCCESS;
Session sess=null;
ResultSet rs = null;
String mesg = "共享成功";
String sql = "";
Connection conn=null;
// request.setCharacterEncoding("gb2312");
String id = request.getParameter("id");
String Modifymenufatherid = request.getParameter("Modifymenufatherid3");
String Modifymenuid = request.getParameter("Modifymenuid3");
String isshare = request.getParameter("isshare");
String menefartherid="";
String treename = request.getParameter("treename3");
try {
sess=HibernateSessionFactory.currentSession();
conn=sess.connection();
conn.setAutoCommit(false);
//每一个人一个人的保存
String choosevalue = request.getParameter("recname");
log.info("choosevalue: "+choosevalue+"\n");
//把原来的全删掉
sql="delete from sharefolder where folderid ='"+id+"' ";
log.info(" delete old sql: "+sql);
conn.createStatement().executeUpdate(sql);
//共享为1
if("1".equals(isshare)){
String userlist[] = Util.split(choosevalue,",");
int listlenth = userlist.length;
String staffname = "";
for(int i=0;i<listlenth;i++){
staffname = userlist[i];
log.info("staffname: "+staffname+"\n");
//会员是否存在
if(Util.checkstaffIsExist(conn,staffname)){
// //是否已添加
// if(Util.checkfolder(conn,staffname,id)){
//
// }else{
// 添加工作属性
sql="insert into sharefolder(staffname,folderid)values('"+staffname+"','"+id+"')";
log.info("insert sharefolder sql: "+sql+"\n");
conn.createStatement().executeUpdate(sql);
// }
}
}
}
if("0".equals(isshare)){
mesg = "共享已取消!";
}
sql = "update folders set isshare ='"+isshare+"' where id='"+id+"'";
conn.createStatement().executeUpdate(sql);
returnStr=WebConstant.FORWARD_SUCCESS;
request.setAttribute(WebConstant.RETURN_Message,mesg);
conn.commit();
} catch (Exception e) {
returnStr=WebConstant.FORWARD_FAIL;
errors.add(ActionErrors.GLOBAL_ERROR,new ActionError("edu.system.excption",e.getMessage()));
this.saveErrors(request,errors);
conn.rollback();
e.printStackTrace();
}finally{
if(null !=conn){
conn.close();
}
HibernateSessionFactory.closeSession();
}
return mapping.findForward(returnStr);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -