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

📄 u04userallaction.java

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

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

import org.apache.log4j.Logger;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.action.DynaActionForm;

import cn.hope.mana.bo.U04StudentBO;
import cn.hope.mana.pojo.Student;
public class U04UserAllAction extends Action{
	public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)throws Exception{
		
	     Logger log = Logger.getLogger(U04StudentAction.class.getName());
	     ActionMessages errors = new ActionMessages();
		DynaActionForm dform = (DynaActionForm)form;
		U04StudentBO u04StudentBO = new U04StudentBO();
		Student st = new Student();
		try{
			String uname = (String) dform.get("username");
			st=u04StudentBO.searchByKey(uname,false);
			String sex = st.getSAandw(); //性别
			if((sex!=null)&&(!sex.equals(""))){
			if(sex.equals("0")){
			    sex="男";	
			}
			else{
				sex="女";
			}
			}
			String tupian = st.getSPh();
			String tupian1 = "/img/"+tupian;//照片
			st.setSPh(tupian1);
			
			String inschool = st.getSInschool();//是否在校
			if((inschool!=null)&&(!inschool.equals(""))){
				if(inschool.equals("1")){
					inschool = "在校";
				}
				else{
					inschool = "不在校";
				}
			}
			
			String marr = st.getSMarriage();
			if((marr!=null)&&(!marr.equals(""))){
				if(marr.equals("0")){
					marr = "未婚";
				}
				else{
					marr = "已婚";
				}
			}
			request.getSession().setAttribute("marr",marr);
			request.getSession().setAttribute("inschool",inschool);
			request.getSession().setAttribute("sex",sex);
			request.getSession().setAttribute("student",st);
			return mapping.findForward("success");
		}catch(Exception e){
			 log.error(e);
			 e.printStackTrace();
			 errors.add(ActionMessages.GLOBAL_MESSAGE,new ActionMessage("errors.u04exception"));
			 return mapping.findForward("errorPage");
		 }
	}
}

⌨️ 快捷键说明

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