adduaaction.java

来自「MM7彩信对接网关示例」· Java 代码 · 共 59 行

JAVA
59
字号
/*
 * Created on 2005-10-24
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.rainbow.mms.manage;

import javax.servlet.http.HttpServletRequest;

import org.hibernate.Session;
import org.hibernate.Transaction;

import com.opensymphony.webwork.ServletActionContext;
import com.opensymphony.webwork.dispatcher.multipart.MultiPartRequestWrapper;
import com.opensymphony.xwork.Action;
import com.rainbow.mms.common.MobileAgent;
import com.rainbow.mms.common.QueryMimeContentSaveStrategy;
import com.rainbow.util.tools.HibernateUtil;

/**
 * 添加手机适配信息
 * @author Rainbow MMS Group Leader —— TrWorks
 */
public class AddUaAction implements Action {

	/* (non-Javadoc)
	 * @see com.opensymphony.xwork.Action#execute()
	 */
	public String execute() throws Exception {
		HttpServletRequest multiWrapper = ServletActionContext
		.getRequest();
		
		MobileAgent ua = new MobileAgent();
		ua.setMobileType(multiWrapper.getParameter("mobileType"));
		ua.setPicType(multiWrapper.getParameter("picType"));
		ua.setSupportGif(multiWrapper.getParameter("beSupportGif").equals("1") == true ? 1 : 0);
		ua.setPicHeight(Integer.parseInt(multiWrapper.getParameter("picHeight")));
		ua.setPicWidth(Integer.parseInt(multiWrapper.getParameter("picWidth")));
		
		String result = ERROR;
		try{
			Session sess = HibernateUtil.currentSession();
			Transaction tx = sess.beginTransaction();
			sess.save(ua);
			tx.commit();
			result = SUCCESS;
		}
		catch(Exception e1){
			e1.printStackTrace();
		}
		finally{
			HibernateUtil.closeSession();
		}
		return result;
	}

}

⌨️ 快捷键说明

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