📄 storefrontdispatchaction.java
字号:
package com.free.struts.storefront.framework;import javax.servlet.http.*;import com.free.struts.storefront.framework.util.IConstants;import com.free.struts.storefront.service.IStorefrontService;import com.free.struts.storefront.service.IStorefrontServiceFactory;import org.apache.struts.actions.DispatchAction;/** * <p>Title: Eclipse Plugin Development</p> * <p>Description: Free download</p> * <p>Copyright: Copyright (c) 2006</p> * <p>Company: Free</p> * @author gan.shu.man * @version 1.0 */public class StorefrontDispatchAction extends DispatchAction { protected IStorefrontService getStorefrontService(){ IStorefrontServiceFactory factory = (IStorefrontServiceFactory)getApplicationObject( IConstants.SERVICE_FACTORY_KEY ); IStorefrontService service = null; try{ service = factory.createService(); }catch( Exception ex ){ log.error( "Problem creating the Storefront Service", ex ); } return service; } /** * Retrieve an object from the application scope by its name. This is * a convience method. */ protected Object getApplicationObject(String attrName) { return servlet.getServletContext().getAttribute(attrName); } /** * Retrieve the UserContainer for the user tier to the request. */ protected UserContainer getUserContainer(HttpServletRequest request) { UserContainer userContainer = (UserContainer)getSessionObject(request, IConstants.USER_CONTAINER_KEY); System.out.println( userContainer ); // Create a UserContainer for the user if it doesn't exist already if(userContainer == null) { userContainer = new UserContainer(); userContainer.setLocale(request.getLocale()); HttpSession session = request.getSession(); session.setAttribute(IConstants.USER_CONTAINER_KEY, userContainer); } return userContainer; } /** * Retrieve a session object based on the request and the attribute name. */ protected Object getSessionObject(HttpServletRequest req, String attrName) { Object sessionObj = null; HttpSession session = req.getSession(false); System.out.println( "Session was " + session ); if ( session != null ){ sessionObj = session.getAttribute(attrName); } return sessionObj; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -