java实现遍历树形菜单两种实现代码分享
程序员文章站
2023-12-22 15:46:16
文本主要向大家分享了java实现遍历树形菜单的实例代码,具体如下。
opensessionview实现:
package org.web;
import ja...
文本主要向大家分享了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实现遍历树形菜单两种实现代码分享的全部内容,希望对大家有所帮助。感兴趣的朋友可以继续参阅本站:、、等,如果有什么不足之处,欢迎留下您的宝贵意见,小编会及时回复大家的。感谢朋友们对本站的支持!