📄 addcountryportaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package cn.bway.foreigntrade.operation.countryport.action;
import java.io.UnsupportedEncodingException;
import java.sql.Connection;
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.WebConstant;
import cn.bway.common.action.BaseAction;
import cn.bway.common.code.codeDao;
import cn.bway.common.dao.HibernateSessionFactory;
import cn.bway.foreigntrade.operation.countryport.impl.CountryportManagerFactory;
import cn.bway.foreigntrade.operation.countryport.model.Countryport;
import cn.bway.foreigntrade.operation.units.impl.UnitsManagerFactory;
import cn.bway.foreigntrade.operation.units.model.Units;
/**
* MyEclipse Struts
* Creation date: 03-07-2008
*
* XDoclet definition:
* @struts.action scope="request" validate="true"
*/
public class AddCountryportAction extends BaseAction {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
ActionErrors errors = new ActionErrors();
Session sess = null;
Transaction tx = null;
String returnStr = null;
Connection conn = null;
try {
request.setCharacterEncoding("utf-8");
} catch (UnsupportedEncodingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
Countryport countryport=new Countryport();
//countryport.setId(request.getParameter("id"));
countryport.setTypes(request.getParameter("types"));
countryport.setPortchiness(request.getParameter("portchiness"));
countryport.setPortenglish(request.getParameter("portenglish"));
countryport.setAreas(request.getParameter("areas"));
countryport.setCountrychiness(request.getParameter("countrychiness"));
countryport.setCountryenlish(request.getParameter("countryenlish"));
countryport.setPortaddress(request.getParameter("portaddress"));
countryport.setNotes(request.getParameter("notes"));
countryport.setPlans(request.getParameter("plans"));
new codeDao().insertCode("countryport", "国家港口", "id","C");
CountryportManagerFactory.getCountryportManager().addCountryport(countryport);
returnStr = WebConstant.FORWARD_INITPAGE;
} catch (Exception e) {//寮傚父澶勭悊锛屽叏灞€杞崲鑷砮rror.jsp
errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("edu.system.excption", e.getMessage()));
this.saveErrors(request, errors);
tx.rollback();
System.out.println(e.getStackTrace());
e.printStackTrace();
} finally {
try {
if (null != conn) {
conn.close();
}
} catch (Exception ex) {
ex.printStackTrace();
}
HibernateSessionFactory.closeSession();
}
return mapping.findForward(returnStr);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -