您好,登錄后才能下訂單哦!
這篇文章將為大家詳細講解有關(guān)java實現(xiàn)遍歷樹形菜單的方法有哪些,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
具體如下。
OpenSessionView實現(xiàn):
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實現(xiàn)
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; } }
關(guān)于“java實現(xiàn)遍歷樹形菜單的方法有哪些”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。