数据未保存

时间:2016-02-11 08:53:21

标签: java

我有这个示例输出

enter image description here

例如,输入的数据应保存;返回并在周四再次进入应该导致“星期四编码:2”但它不会。

这是我的控制器:

        BusName = request.getParameter("busName");
        PlateNumber = request.getParameter("plateNo");
        DriverAssigned = request.getParameter("driverAssigned");


        String firstString = PlateNumber.substring(0, 2);
        String secondString = PlateNumber.substring(3, 5);

        if (firstString.matches(".*[A-Z].*") && secondString.matches(".*\\d.*")){

        CalculatorBean beanCalc = BeanFactory.getInstance(BusName, PlateNumber, DriverAssigned);

        HttpSession session = request.getSession();
        session.setAttribute("deJesusBean", beanCalc);

        RequestDispatcher dispatcher = request.getRequestDispatcher("displayresult.jsp");           
        dispatcher.forward(request, response);

这是我的汇编程序:

public class BeanFactory {

public static CalculatorBean getInstance(String busName, String plateNo, String driverAssigned){
    CalculatorBean calcBean = new CalculatorBean();
    calcBean.setBusName(busName);
    calcBean.setPlateNo(plateNo);
    calcBean.setDriverAssigned(driverAssigned);
    calcBean.compute();
    return calcBean;
}

}

以下是我模型中的逻辑:

    public void compute(){
    char x = plateNo.charAt(5);

    if (x == '1' || x == '2'){
        dayOfCoding = "Monday";
        mondayCoding = mondayCoding + 1;
    }
    else if (x == '3' || x == '4'){
        dayOfCoding = "Tuesday";
        tuesdayCoding = tuesdayCoding + 1;
    }
    else if (x == '5' || x == '6'){
        dayOfCoding = "Wednesday";
        wednesdayCoding = wednesdayCoding + 1;
    }
    else if (x == '7' || x == '8'){
        dayOfCoding = "Thursday";
        thursdayCoding = thursdayCoding + 1;
    }
    else if (x == '9' || x == '0'){
        dayOfCoding = "Friday";
        fridayCoding = fridayCoding + 1;

以下是我在displayResult.jsp上调用它的方式

    ${deJesusBean.tuesdayCoding}

非常感谢您的帮助。对不起,如果这篇文章再次写完,我现在在这里澄清了一些事情。

0 个答案:

没有答案