ActionRedirect 作转向,但有时候可以,有时候不可以,不知道为什么
代码如下:private ActionForward callbackOperation(Charge charge,
HttpServletRequest request) throws AppException {
System.out.println("-----开始执行callbackOperation----------"); ActionRedirect redirect = new ActionRedirect("/agent/agent.do");
redirect.addParameter("thisAction", "agentInfoById"); final String chargeType = charge.getType();
final String re = charge.getRe(); try {
if (Charge.CHARGE_TYPE_SELF.equals(chargeType)) {
return redirect;
} else if (Charge.CHARGE_TYPE_TRANSACTION.equals(chargeType)) {
redirect = new ActionRedirect("/transaction/transaction.do");
redirect.addParameter("thisAction",
"transactionPaymentReturnByBank");
redirect.addParameter("transactionNo", re);
} else if (Charge.CHARGE_TYPE_NOACCOUNT.equals(chargeType)) {
redirect = new ActionRedirect("/cooperate/gateway.do");
redirect.addParameter("service",
"direct_payment_for_no_account");
redirect.addParameter("re", re);
} else if (Charge.CHARGE_TYPE_DIRECTPAYMENT.equals(chargeType)) { //例如我现在执行这里
System.out.println("--0-开始redirect,订单号:" + charge.getOrderNo());
redirect = new ActionRedirect("/cooperate/gateway.do");
redirect.addParameter("service", "direct_payment_by_bank");
redirect.addParameter("re", re);
System.out.println("-1-开始redirect,订单号:" + charge.getOrderNo());
} else if (Charge.CHARGE_TYPE_OTHER.equals(chargeType)) {
return redirect;
}
} catch (Exception ex) {
System.out.println("callbackOperation异常," + ex.getMessage());
return null;
}
System.out.println("------------开始执行redirect------" + chargeType
+ ",Charge.CHARGE_TYPE_DIRECTPAYMENT.equals(chargeType)="
+ Charge.CHARGE_TYPE_DIRECTPAYMENT.equals(chargeType));
return redirect;
}
可以看到我们执行的那里
最后都是return redirect的,但为什么有时候可以转,有时候不可以呢
代码如下:private ActionForward callbackOperation(Charge charge,
HttpServletRequest request) throws AppException {
System.out.println("-----开始执行callbackOperation----------"); ActionRedirect redirect = new ActionRedirect("/agent/agent.do");
redirect.addParameter("thisAction", "agentInfoById"); final String chargeType = charge.getType();
final String re = charge.getRe(); try {
if (Charge.CHARGE_TYPE_SELF.equals(chargeType)) {
return redirect;
} else if (Charge.CHARGE_TYPE_TRANSACTION.equals(chargeType)) {
redirect = new ActionRedirect("/transaction/transaction.do");
redirect.addParameter("thisAction",
"transactionPaymentReturnByBank");
redirect.addParameter("transactionNo", re);
} else if (Charge.CHARGE_TYPE_NOACCOUNT.equals(chargeType)) {
redirect = new ActionRedirect("/cooperate/gateway.do");
redirect.addParameter("service",
"direct_payment_for_no_account");
redirect.addParameter("re", re);
} else if (Charge.CHARGE_TYPE_DIRECTPAYMENT.equals(chargeType)) { //例如我现在执行这里
System.out.println("--0-开始redirect,订单号:" + charge.getOrderNo());
redirect = new ActionRedirect("/cooperate/gateway.do");
redirect.addParameter("service", "direct_payment_by_bank");
redirect.addParameter("re", re);
System.out.println("-1-开始redirect,订单号:" + charge.getOrderNo());
} else if (Charge.CHARGE_TYPE_OTHER.equals(chargeType)) {
return redirect;
}
} catch (Exception ex) {
System.out.println("callbackOperation异常," + ex.getMessage());
return null;
}
System.out.println("------------开始执行redirect------" + chargeType
+ ",Charge.CHARGE_TYPE_DIRECTPAYMENT.equals(chargeType)="
+ Charge.CHARGE_TYPE_DIRECTPAYMENT.equals(chargeType));
return redirect;
}
可以看到我们执行的那里
最后都是return redirect的,但为什么有时候可以转,有时候不可以呢
redirect.addParameter("service", "direct_payment_by_bank");
redirect.addParameter("re", re);return redirect最后应该是执行("/cooperate/gateway.do?service=direct_payment_by_bank 这个的,但是没有执行到,有时候又可以
下面的 else if 中 怎么 又有 new ActionRedirect 转向呢?
两次 转向 行吗?