一.实现目标 首先会有一个存放中国行政区域数据的一个txt文件,用java读取并解析出来,并在页面上通过下拉框的形式展示出来.实现效果如下图,当选择完省份后,在选择该省份下的城市,然后在选择该城市下的县区这样逐级显示: 二.代码实现: 1. 先创建一个javaBean,用来存放基本数据: public class Area { private String code ;//行政编码 private String name;//名称 private int level;//行政级别 0:省/直辖市
一.创建数据库并设置编码. A) create database oa default character set utf8. 二.MyEclipse工程 A) 在Myeclipse里创建web工程,并设置编码为utf8. B) 添加框架环境 1.添加Junit4 library(Myeclipse自带) 2.添加Struts2环境 ①所需Jar包 ②配置文件:拷贝一个struts.xml模版到src目录,进行适当修改,在web.xml里配上需要的代码. struts.xml <?xml ver
原文:分享非常有用的Java程序 (关键代码)(四)---动态改变数组的大小 /** * Reallocates an array with a new size, and copies the contents * * of the old array to the new array. * * @param oldArray the old array, to be reallocated. * * @param newSize the new array size. * * @return
原文:分享非常有用的Java程序 (关键代码) (二)---列出文件和目录 File dir = new File("directoryName"); String[] children = dir.list(); if (children == null) { // Either dir does not exist or is not a directory } else { for (int i=0; i < children.length; i++) { // Get f