[JAVA] insert servlet

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { request.setCharacterEncoding("utf-8");

	///////////////////////////////////////////////

// [Close] button press judgment /////////////////////////////////////////////// String type = request.getParameter("submitClose2"); if (type! = null) {// Originally, it is a comparison with the "close" character string, but since it is garbled, it is a null comparison. return mapping.findForward("close"); }

	///////////////////////////////////////////////

// [Apply] button press judgment /////////////////////////////////////////////// type = request.getParameter("submitshinsei"); if (type! = null) {// Originally, it is a comparison with the "application" character string, but since it is garbled, it is a null comparison. return setKoutuhi(mapping, form, request, response); }

	///////////////////////////////////////////////

// [Initial processing] /////////////////////////////////////////////// return init(mapping, form, request, response);

}

/**

//交通費新規申請画面の日付のプルダウン作成 List selYmdList = makeYmdList(); ksForm.setSinSelYmdList(selYmdList);

	request.getSession().setAttribute("selYmdList", selYmdList);

// Transition destination is own screen (defined in struts-config.xml) return mapping.findForward("success"); }

//交通費新規申請画面の日付のプルダウン作成メソッド private List makeYmdList() { List selYmdList = new ArrayList(); int mm = 20170801; for (int i=0;i<31;i++) { KbnData dd = new KbnData(); String vDay = String.valueOf(mm++); dd.setKey(vDay); dd.setValue(vDay.substring(0, 4) + "/" + vDay.substring(4, 6) + "/" + vDay.substring(6, 8)); selYmdList.add(dd); } return selYmdList; }

private ActionForward setKoutuhi(ActionMapping mapping, ActionForm form, HttpServletRequest request,
		HttpServletResponse response) throws Exception {

//formにあるJSPより取得したデータをKshinseiForm型にする KshinseiForm ksForm = (KshinseiForm)form;

//JSPより取得したデータをSQLでインサートするほうへ移す DKoutuhiInfoData insertData = new DKoutuhiInfoData(); insertData.setShainId("111003"); insertData.setKinmuDay(ksForm.getSinSelYmd()); insertData.setGyoumuNo(ksForm.getSinGyoumuNo()); insertData.setVisit(ksForm.getSinVisit()); insertData.setDepartArea(ksForm.getSinDepartArea()); insertData.setArrivalArea(ksForm.getSinArrivalArea()); insertData.setVehicle(ksForm.getSinVehicle()); insertData.setKinngaku(ksForm.getSinKinngaku()); insertData.setEtc(ksForm.getSinEtc()); insertData.setJoutai ("application"); insertData.setDelKbn("0"); insertData.setEntryId("111003"); insertData.setUpdateId("111003");

// Data INSERT class MKoutuhiInfo info = new MKoutuhiInfo();

// Send data to INSERT class list data info.setKoutuhiInfo(insertData);

// Transition destination is own screen (defined in struts-config.xml) return mapping.findForward("kmeisai");

}

Recommended Posts

insert servlet
Servlet
Servlet learning
update servlet
Servlet movement
[Servlet] Basic method