zoukankan      html  css  js  c++  java
  • java实现遍历树形菜单方法——OpenSessionView实现

     /**  
    * @Title: OpenSessionView.java
    * @Package org.util
    * @Description: TODO该方法的主要作用:
    * @author A18ccms A18ccms_gmail_com  
    * @date 2017-5-6 下午1:48:25
    * @version V1.0  
    */
    package org.web;
    
    import java.io.IOException;
    
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    
    import org.dao.BaseHibernateDao;
    import org.hibernate.Hibernate;
    import org.hibernate.Session;
    import org.hibernate.Transaction;
    
     /**   
     *    
     * 项目名称:votedemo   
     * 类名称:OpenSessionView   
     * 类描述:   让session 始终保持着一个打开的状态
     * 创建人:Mu Xiongxiong  
     * 创建时间:2017-5-6 下午1:48:25   
     * 修改人:Mu Xiongxiong   
     * 修改时间:2017-5-6 下午1:48:25   
     * 修改备注:   
     * @version    
     *    
     */
    public class OpenSessionView extends BaseHibernateDao implements Filter {
    
    	/**(非 Javadoc)
    	 * <p>Title: destroy</p>
    	 * <p>Description(描述): </p>
    	 * @see javax.servlet.Filter#destroy()
    	 */
    
    	@Override
    	public void destroy() {
    		// TODO Auto-generated method stub
    
    	}
    
    	/**(非 Javadoc)
    	 * <p>Title: doFilter</p>
    	 * <p>Description(描述): </p>
    	 * @param arg0
    	 * @param arg1
    	 * @param arg2
    	 * @throws IOException
    	 * @throws ServletException
    	 * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
    	 */
    
    	@Override
    	public void doFilter(ServletRequest arg0, ServletResponse arg1,
    			FilterChain arg2) throws IOException, ServletException {
    		Session session = null;
    		Transaction tx  = null;
    		
    		try {
    			session = getSession();
    			tx = session.beginTransaction();
    			arg2.doFilter(arg0, arg1);
    			tx.commit();
    		} catch (Exception e) {
    			e.printStackTrace();
    			tx.rollback();
    		}finally{
    			closeSession();
    		}
    		
    
    	}
    
    	/**(非 Javadoc)
    	 * <p>Title: init</p>
    	 * <p>Description(描述): </p>
    	 * @param arg0
    	 * @throws ServletException
    	 * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
    	 */
    
    	@Override
    	public void init(FilterConfig arg0) throws ServletException {
    		// TODO Auto-generated method stub
    
    	}
    
    }
    

  • 相关阅读:
    ZJOI2019二轮游记
    Luogu P5284 [十二省联考2019]字符串问题
    Luogu P5309 [Ynoi2012]D1T1
    Luogu P5292 [HNOI2019]校园旅行
    LOJ #6052. 「雅礼集训 2017 Day11」DIV
    Luogu P5279 [ZJOI2019]麻将
    LOJ #6060. 「2017 山东一轮集训 Day1 / SDWC2018 Day1」Set
    Luogu P5283 [十二省联考2019]异或粽子
    Luogu P5290 [十二省联考2019]春节十二响
    Luogu P5285 [十二省联考2019]骗分过样例
  • 原文地址:https://www.cnblogs.com/a1111/p/7459711.html
Copyright © 2011-2022 走看看