Design organization tree to implement interface organization tree through Java Mosaic XML tree Configuration Dynamic decision of menu tree display or not, arrange priority __ Database

Source: Internet
Author: User
Tags stringbuffer

Structure design of database organization tree

Java implementation code, splicing XML organization tree

Public String Loadareatree () {StringBuffer areatreestr = new StringBuffer ();
		
		Areatreestr.append ("<>"); Check out all the countries in the first level region list<area> countrylist = Hibernatetemplate.getsessionfactory (). Opensession (). CreateQuery ("
		From area p where P.parentareano = ' # ' and p.isvisible = ' true ' ORDER by P.leafno '). List (); if (countrylist!= null && countrylist.size () > 0) {for (area countryarea:countrylist) {Areatreestr.ap
				
				Pend ("<country areaname=\" "+countryarea.getareaname () +" "Urls=\" "+countryarea.geturls () +" ">");
											Check out all provinces in the second tier (under the country) list<area> provincearealist = Hibernatetemplate.getsessionfactory (). Opensession ()
											. CreateQuery ("from area p where P.parentareano =:countryareano and p.isvisible = ' true ' ORDER by P.leafno")
				. SetString ("Countryareano", Countryarea.getareano (). toString ()). List (); if (provincearealist!= null && provincearealist.size () > 0) {for (area Provincearea:provincearealiST) {areatreestr.append ("<province areaname=\" "+provincearea.getareaname () +" \ urls=\ "" +provincearea.geturls ()
						
						+ ">");
													Check out all cities in the third-tier region (under the province) list<area> cityarealist = Hibernatetemplate.getsessionfactory (). Opensession ()
													. CreateQuery ("from area p where P.parentareano =:p Rovinceareano and p.isvisible = ' true ' ORDER by P.leafno")
						. SetString ("Provinceareano", Provincearea.getareano (). toString ()). List (); if (cityarealist!= null && cityarealist.size () > 0) {for (area cityarea:cityarealist) {Areatr Eestr.append ("<city areaname=\" "+cityarea.getareaname () +" \ urls=\ "" +cityarea.geturls () + "></city>"
							);
					} areatreestr.append ("</province>");
			} areatreestr.append ("</country>");
		Return Areatreestr.append ("</>"). ToString ();
		}else{return ""; }
	}


Interface display

Clicking on the menu will link to the specified URL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.