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

作者:kgmucom   在线用户:35
风之恋奇迹私服技术网是一家提供最新互联网编程技术网站

我们在开发程序的时候,经常会使用树形菜单进行布局,接下来爱站技术频道小编就给大家介绍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 {
	/**(非 doc)
	 * 

Title: destroy

*

Description(描述):

* @see javax.servlet.Filter#destroy() */ @Override public void destroy() { // TODO Auto-generated method stub } /**(非 Javadoc) *

Title: doFilter

*

Description(描述):

* @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) *

Title: init

*

Description(描述):

* @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实现遍历树形菜单两种实现代码分享,相信大家了解的差不多了,如果还有想要学习的内容,也可以在下面给小编留言哦。

提供最全面的奇迹sf开服版本和最新的奇迹私服开服技术信息,奇迹私服文库让每一位奇迹私服玩家找到自己需要的版本技术文章

上一篇:Java多态性定义与用法实例详解

下一篇:spring boot的maven配置依赖详解

请发表您的评论