📄 updatepaymentcardaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package org.bestteam.web.struts.action;
import java.lang.reflect.InvocationTargetException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;
import org.bestteam.dao.PaymentCardDao;
import org.bestteam.domain.CreditCard;
import org.bestteam.domain.PaymentCard;
import org.bestteam.service.PaymentCardService;
/**
* MyEclipse Struts
* Creation date: 02-03-2007
*
* XDoclet definition:
* @struts.action path="/updatePaymentCard" name="updatePaymentCardForm" input="/updatePaymentCard.jsp" scope="request" validate="true"
*/
public class UpdatePaymentCardAction extends Action {
private PaymentCardService paymentCardService;
public void setPaymentCardService(PaymentCardService paymentCardService) {
this.paymentCardService = paymentCardService;
}
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
ActionForward forward = mapping.findForward("failure");
try {
String cardId = (String) PropertyUtils.getProperty(form, "cardId");
CreditCard creditCard = new CreditCard();
creditCard.setId(new Integer(cardId));
PaymentCard paymentCard = new PaymentCard();
paymentCard.setUserId(new Integer(request.getSession().getAttribute("userId").toString()));
paymentCard.setCreditCard(creditCard);
boolean state = paymentCardService.updatePaymentCard(paymentCard);
if (state) {
forward = mapping.findForward("success");
request.setAttribute("Message", "支付宝账号修改成功!");
request.setAttribute("paymentCard", paymentCard);
request.setAttribute("forwardPage", "userinfo.jsp");
}
else {
request.setAttribute("errorMessage", "银行账号不存在!");
request.setAttribute("forwardPage", "userinfo.jsp");
}
} catch (IllegalAccessException e) {
request.setAttribute("errorMessage", "参数不正确");
request.setAttribute("forwardPage", "userinfo.jsp");
e.printStackTrace();
} catch (InvocationTargetException e) {
request.setAttribute("errorMessage", "参数不正确");
request.setAttribute("forwardPage", "userinfo.jsp");
e.printStackTrace();
} catch (NoSuchMethodException e) {
request.setAttribute("errorMessage", "参数不正确");
request.setAttribute("forwardPage", "userinfo.jsp");
e.printStackTrace();
}
return forward;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -