亲宝软件园·资讯

展开

java实现遍历树形菜单 java实现遍历树形菜单两种实现代码分享

一步一步完善 人气:0
想了解java实现遍历树形菜单两种实现代码讲解的相关内容吗,一步一步完善在本文为您仔细讲解java实现遍历树形菜单的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:java,遍历树形菜单,java,遍历菜单,java,树形结构遍历,下面大家一起来学习吧。

文本主要向大家分享了java实现遍历树形菜单的实例代码,具体如下。

OpenSessionView实现:

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;
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
	}
}

TreeAction实现

package org.web;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.Service.IVoteTreeService;
import org.Service.impl.VoteTreeServiceImpl;
import com.alibaba.fastjson.JSON;
import com.opensymphony.xwork2.ActionSupport;
public class TreeAction extends ActionSupport {
	private JSONArray treejson;
	private IVoteTreeService voteService = new VoteTreeServiceImpl();
	public String getTree(){
		treejson = voteService.getTreeJson();
		return SUCCESS;
	}
	public JSONArray getTreejson() {
		return treejson;
	}
	public void setTreejson(JSONArray treejson) {
		this.treejson = treejson;
	}
}

总结

以上就是本文关于java实现遍历树形菜单两种实现代码分享的全部内容,希望对大家有所帮助。感兴趣的朋友可以继续参阅本站:java中变量和常量详解浅谈java中==以及equals方法的用法创建并运行一个java线程方法介绍等,如果有什么不足之处,欢迎留下您的宝贵意见,小编会及时回复大家的。感谢朋友们对本站的支持!

加载全部内容

相关教程
猜你喜欢
用户评论