editaccountpageaction.java
来自「Spring +Web 的完整 MyEclipse 项目源码,使用者可以作为入门」· Java 代码 · 共 64 行
JAVA
64 行
package org.digitstore.web.struts.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.digitstore.domain.Account;
import org.digitstore.service.AccountManager;
import org.digitstore.service.ManagerFactory;
import org.digitstore.service.ProductManager;
import org.digitstore.web.struts.form.AccountActionForm;
import org.springframework.beans.support.PagedListHolder;
public class EditAccountPageAction extends SecureBaseAction {
/*
* (non-Javadoc)
*
* @see org.digitstore.web.struts.action.SecureBaseAction#doExecute(org.apache.struts.action.ActionMapping,
* org.apache.struts.action.ActionForm,
* javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse)
*/
protected ActionForward doExecute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
// TODO Auto-generated method stub
AccountActionForm acctForm = (AccountActionForm) form;
if (AccountActionForm.VALIDATE_EDIT_ACCOUNT.equals(acctForm
.getValidate())) {
AccountManager accManager = ManagerFactory.createAccountManager();
ProductManager proManager = ManagerFactory.createProductManager();
acctForm.getAccount().setListOption(
request.getParameter("account.listOption") != null);
acctForm.getAccount().setBannerOption(
request.getParameter("account.bannerOption") != null);
Account account = acctForm.getAccount();
//System.out.println("1"+account.getFirstName());
accManager.updateAccount(account);
acctForm.setAccount(accManager.getAccount(account.getUsername()));
//System.out.println("2"+acctForm.getAccount().getFirstName());
//System.out.println(new
// String(acctForm.getAccount().getFirstName().getBytes("iso-8859-1"),"UTF-8"));
PagedListHolder myList = new PagedListHolder(proManager
.getProductListByCategory(account.getFavouriteCategoryId()));
myList.setPageSize(4);
acctForm.setMyList(myList);
request.getSession().setAttribute("accountForm", acctForm);
request.getSession().removeAttribute("workingAccountForm");
return mapping.findForward("success");
} else {
request
.setAttribute(
"message",
"Your account was not updated because the submitted information was not validated.");
return mapping.findForward("failure");
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?