?? loginaction.java
字號:
package netstore.security;
import java.util.Locale;
import javax.servlet.http.*;
import javax.servlet.ServletContext;
import org.apache.struts.action.*;
import org.apache.struts.util.MessageResources;
import netstore.businessobjects.Customer;
import netstore.framework.exceptions.*;
import netstore.framework.SessionContainer;
import netstore.framework.NetstoreBaseAction;
import netstore.framework.util.IConstants;
import netstore.service.INetstoreService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Implements the logic to authenticate a user for the netstore application.
*/
public class LoginAction extends NetstoreBaseAction {
protected static Log log = LogFactory.getLog( NetstoreBaseAction.class );
/**
* Called by the controller when the a user attempts to login to the
* netstore application.
*/
public ActionForward execute( ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response )
throws Exception{
MessageResources messages=getResources(request);
ActionMessages errors=new ActionMessages();
// Get the user's login name and password. They should have already
// validated by the ActionForm.
String email = ((LoginForm)form).getEmail();
String password = ((LoginForm)form).getPassword();
// Obtain the ServletContext
ServletContext context = getServlet().getServletContext();
// Login through the security service
INetstoreService serviceImpl = getNetstoreService();
Customer customer= serviceImpl.authenticate(email, password);
SessionContainer existingContainer = getSessionContainer(request);
existingContainer.setCustomer(customer);
return mapping.findForward(IConstants.SUCCESS_KEY);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -