您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
这篇文章将为大家详细讲解有关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实现遍历树形菜单的方法有哪些”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。