研修の下記プログラムが動作せず、困っています。
環境はecripse4.3 stルts tomcat6 です。
どなたかアドバイスをいただけませんか?
package jp.co.haduki.strutssample.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jp.co.haduki.strutssample.actionform.SampleForm;
import jp.co.haduki.strutssample.logic.SampleLogic;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
public class SampleAction extends Action {
public ActionForward doPost(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, Object calString) { SampleLogic logic = new SampleLogic(); SampleForm sampleForm = (SampleForm) form; request.getAttribute("calString"); if (sampleForm.getText1() != null) { if (!sampleForm.getText1().equals("")) { logic.executeBusinessLogic(form); return mapping.findForward("success"); } } return mapping.findForward("error"); }
}
package jp.co.haduki.strutssample.action;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jp.co.haduki.strutssample.actionform.CalkForm;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
public class calkAction extends Action {
public void doGet(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{ CalkForm calkForm = (CalkForm) form; String text1 = calkForm.getText1(); String text2 = calkForm.getText2(); String text3 = calkForm.getText3(); int text1calk = Integer.parseInt(text1); int text2calk = Integer.parseInt(text2); int text3calk = Integer.parseInt(text3); Calendar cal = Calendar.getInstance(); cal.add(Calendar.YEAR,-text1calk); cal.add(Calendar.MONTH,-text2calk); cal.add(Calendar.DATE,-text3calk); String calString = new SimpleDateFormat("yyyy/MM/dd").format(cal.getTime()); request.setAttribute("calString", calString); response.sendRedirect("/Sample"); mapping.findForward("calk"); }
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page contentType="text/html; charset=Windows-31J" pageEncoding="Windows-31J"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
回答1件
あなたの回答
tips
プレビュー