📄 viewcustomeraction.java
字号:
/* * * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. * * This software is the proprietary information of Sun Microsystems, Inc. * Use is subject to license terms. * The code in this example is offered under the license at: * http://wireless.java.sun.com/berkeley_license.html * */import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.http.HttpSession;import java.io.*;import java.util.*;import javax.naming.*;import javax.ejb.*;import customerejb.*;import customerejb.CustomerTO;import customerejb.ICustomerTO;import org.apache.struts.action.Action;import org.apache.struts.action.ActionError;import org.apache.struts.action.ActionErrors;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionForward;import org.apache.struts.action.ActionMapping;import org.apache.struts.util.MessageResources;public class ViewCustomerAction extends Action { public static final String custTOAttribute = "customerForm"; /** * This is the method called on by ActionServlet * when a request is made for the action. * "mapping" is a class representation of the * action as defined in action.xml. * "form" is the form bean created for * this action */ public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)throws java.io.IOException { System.out.println("ViewCustomerAction "); CustomerTO customerTO= null; CustomerDelegate bdelegate = null; String customerId = request.getUserPrincipal().getName(); try { bdelegate = new CustomerDelegate(); customerTO= (CustomerTO)bdelegate.getCustomer(customerId); } catch (Exception e) { e.printStackTrace(); return mapping.findForward("error"); } CustomerForm customerForm = new CustomerForm(); customerForm.setCustomerId(customerId ); customerForm.setFirstName(customerTO.getFirstName()); customerForm.setLastName(customerTO.getLastName()); customerForm.setStreet(customerTO.getStreet()); customerForm.setCity(customerTO.getCity()); customerForm.setState(customerTO.getState()); customerForm.setZip(customerTO.getZip()); customerForm.setPhone(customerTO.getPhone()); customerForm.setEmail(customerTO.getEmail()); System.out.println("ViewCustomerAction Storing the customerForm in sessionobject"); HttpSession session = request.getSession(); session.setAttribute(custTOAttribute, customerForm); return mapping.findForward("success"); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -