u05tinofaction.java

来自「持久层hibernate技术使用的一个例子」· Java 代码 · 共 80 行

JAVA
80
字号
package cn.hope.front.action;



import java.util.HashMap;
import java.util.Map;

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.LookupDispatchAction;

import cn.hope.front.bo.U05TInfoBO;

import cn.hope.front.pojo.TInfo;

public class U05TInofAction extends LookupDispatchAction {

	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		HttpSession session=request.getSession();
		//U05TInfoForm tform =(U05TInfoForm)form;
		//System.out.println(tform.getTBirth());
		try{
			TInfo tInfo = new TInfo();
			U05TInfoBO u05TInfoBO = new U05TInfoBO();
			tInfo = u05TInfoBO.find("wudibo");
			
			if(StringUtils.isEmpty(request.getParameter("asd")))
			{
				if(tInfo.getTSex().equals("0")){
					tInfo.setTSex("男");
				}
				else{
					tInfo.setTSex("女");
				}
				if(tInfo.getTMarry().equals("0")){
					tInfo.setTMarry("已");
				}
				else{
					tInfo.setTMarry("未");
				}
				session.setAttribute("tInfoList",tInfo);
				return mapping.findForward("U05TInfo");
			}
			else
			{
				request.setAttribute("tform",form);
				session.setAttribute("tInfoList",tInfo);
				return mapping.findForward("c00");
			}
		} 
		catch (Exception e) {
			e.printStackTrace();
		}
		return mapping.findForward("error");
	}
	
	public ActionForward retrun(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		return mapping.findForward("U05TInfo");
	}
	
	protected Map getKeyMethodMap() {
		HashMap hm = new HashMap();
		hm.put("tInfo.jsp.executeButton.name","execute");
		hm.put("tInfo.jsp.retrunButton.name","return");
		return hm;
	}

}

⌨️ 快捷键说明

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