最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
java实现遍历树形菜单两种实现代码分享
时间:2022-06-29 01:05:54 编辑:袖梨 来源:一聚教程网
文本主要向大家分享了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) *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; } }
相关文章
- 2024金摇杆奖年度游戏名单 11-22
- 用针在纸上绣画是哪种非遗技艺 蚂蚁新村11月21日答案最新 11-22
- 重返未来1999纸信圈儿什么时候up 为什么故事集卡池活动介绍 11-22
- 重返未来1999雾中盛会怎么玩 UTTU聚光专栏雾中盛会活动介绍 11-22
- 光遇姆明季后续版本怎么玩 光遇音乐节宴会节活动介绍 11-22
- 无期迷途四星装束是谁 无期迷途首个四星装束剪影介绍 11-22