⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 u05a200action.java

📁 持久层hibernate技术使用的一个例子
💻 JAVA
字号:
package cn.hope.mana.action;

import java.util.Iterator;
import java.util.List;
import java.util.Vector;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.commons.lang.StringUtils;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;


import cn.hope.mana.bo.U05BO;
import cn.hope.mana.form.U05A200Form;
import cn.hope.mana.pojo.TQuestion;
import cn.hope.mana.pojo.U07CommonListVO;
import cn.hope.mana.pojo.dao.TTestDAO;

public class U05A200Action extends DispatchAction {

	public ActionForward update(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {	
		
		U05BO u05bo = new U05BO();
		U05A200Form u05 = (U05A200Form) form; 
		TTestDAO tTestDAO = new TTestDAO();
		
		String []a = request.getParameterValues("tqId");
		int id = u05bo.searchTest(a);
		Vector v = tTestDAO.searchNotInTest(a);
		
		if(a!=null && a.length>0){
			
			if(id>0){
				String aa = "删除失败!题号为:";
				for(int j=0;j<v.size();j++){
					aa=aa+","+v.get(j);
				}
				aa+=" 的考题在试卷中以有,无法删除!";
				String aaa = aa.replaceFirst(",","");
				u05.setAa(aaa);
				u05.setI(1);
				return mapping.findForward("success1");
			}else{
				
				u05bo.delete(a);    
				
				String subject = u05.getSubject();			//获得学科ID
				String type = u05.getType();				//题型ID
				
				Integer sSid = new Integer(subject);		//转换成INTEGER
				Integer tqtId = new Integer(type);
				
		        //分页
				
				U07CommonListVO cl_vo = new U07CommonListVO();
				int start = 0;
				boolean isEq = false;
				
				if (StringUtils.isNotEmpty(request.getParameter("start"))) {
					start = Integer.parseInt(request.getParameter("start"));
				}
				if (StringUtils.isNotEmpty(request.getParameter("isEq"))) {
					isEq = true;
				}
				cl_vo = u05bo.serach(sSid,tqtId, start, isEq);
				
				//截取“考题内容”的长度
				
				List list = cl_vo.getRs();
				
				Iterator it = list.iterator();
				
				while(it.hasNext()){
					TQuestion tQuestion = (TQuestion)it.next();
					String name = tQuestion.getTqName();
					if(name.length()>11){
						name = name.substring(0,10);
						tQuestion.setTqName(name);
					}
				}
				
				HttpSession session = request.getSession();
				
				session.setAttribute("fenye",cl_vo);
				
				return mapping.findForward("success");
			}	
		}

		return mapping.findForward("success");
	}
	
	public ActionForward search(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		U05A200Form u05 = (U05A200Form) form;     
		U05BO u05bo = new U05BO();
		
		String subject = u05.getSubject();			//获得学科ID
		String type = u05.getType();				//题型ID
		
		Integer sSid = new Integer(subject);		//转换成INTEGER
		Integer tqtId = new Integer(type);
		
        //分页
		
		U07CommonListVO cl_vo = new U07CommonListVO();
		int start = 0;
		boolean isEq = false;
		
		if (StringUtils.isNotEmpty(request.getParameter("start"))) {
			start = Integer.parseInt(request.getParameter("start"));
		}
		if (StringUtils.isNotEmpty(request.getParameter("isEq"))) {
			isEq = true;
		}
		cl_vo = u05bo.serach(sSid,tqtId, start, isEq);
		
		//截取“考题内容”的长度
		
		List list = cl_vo.getRs();
		
		Iterator it = list.iterator();
		
		while(it.hasNext()){
			TQuestion tQuestion = (TQuestion)it.next();
			String name = tQuestion.getTqName();
			if(name.length()>11){
				name = name.substring(0,10);
				tQuestion.setTqName(name);
			}
		}
				
		request.getSession().setAttribute("fenye",cl_vo);
		
		return mapping.findForward("success");
	}

	public ActionForward back(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {	
		
		return mapping.findForward("back");
	}
	
	public ActionForward returnSearch(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		   
		U05BO u05bo = new U05BO();
		U05A200Form u05 = (U05A200Form) form; 
		
		String subject = (String)request.getSession().getAttribute("U05subject");			//获得学科ID
		String type = (String)request.getSession().getAttribute("U05type");				//题型ID
		
		Integer sSid = new Integer(subject);		//转换成INTEGER
		Integer tqtId = new Integer(type);
		
        //分页
		
		U07CommonListVO cl_vo = new U07CommonListVO();
		int start = 0;
		boolean isEq = false;
		
		if (StringUtils.isNotEmpty(request.getParameter("start"))) {
			start = Integer.parseInt(request.getParameter("start"));
		}
		if (StringUtils.isNotEmpty(request.getParameter("isEq"))) {
			isEq = true;
		}
		cl_vo = u05bo.serach(sSid,tqtId, start, isEq);
		
		//截取“考题内容”的长度
		
		List list = cl_vo.getRs();
		
		Iterator it = list.iterator();
		
		while(it.hasNext()){
			TQuestion tQuestion = (TQuestion)it.next();
			String name = tQuestion.getTqName();
			if(name.length()>11){
				name = name.substring(0,10);
				tQuestion.setTqName(name);
			}
		}
				
		request.getSession().setAttribute("fenye",cl_vo);
		
		u05.setSubject(sSid.toString());
		u05.setType(tqtId.toString());
		
		return mapping.findForward("success");
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -