Using Spring MVC 3.1+ WebApplicationInitializer to programmatically configure session-config and error-page

后端 未结 5 2133
迷失自我
迷失自我 2020-12-14 18:19

WebApplicationInitializer provides a way to programmatically represent a good portion of a standard web.xml file - the servlets, filters, listeners.

However I have

5条回答
  •  天命终不由人
    2020-12-14 18:38

    In web.xml

    
        3
    -->
    
        
    
      
    
    

    Listener Class

    public class ProductBidRollBackListener implements HttpSessionListener {
    
     @Override
     public void sessionCreated(HttpSessionEvent httpSessionEvent) {
        //To change body of implemented methods use File | Settings | File Templates.
    
     }
    
     @Override
     public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
        HttpSession session=httpSessionEvent.getSession();
        WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(session.getServletContext());
        ProductService productService=(ProductService) context.getBean("productServiceImpl");
        Cart cart=(Cart)session.getAttribute("cart");
        if (cart!=null && cart.getCartItems()!=null && cart.getCartItems().size()>0){
            for (int i=0; i

提交回复
热议问题