javajava二级联动下拉列表问题

博客分类:
* @File name:
CreateExcelMoBusiness.java
* @Create on:
* @ChangeList
* ---------------------------------------------------
ChangeReasons
import java.io.FileOutputS
import java.util.HashM
import org.apache.poi.hssf.usermodel.DVC
import org.apache.poi.hssf.usermodel.HSSFDataV
import org.apache.poi.hssf.usermodel.HSSFW
import org.apache.poi.ss.usermodel.C
import org.apache.poi.ss.usermodel.CellS
import org.apache.poi.ss.usermodel.DataV
import org.apache.poi.ss.usermodel.F
import org.apache.poi.ss.usermodel.IndexedC
import org.apache.poi.ss.usermodel.N
import org.apache.poi.ss.usermodel.R
import org.apache.poi.ss.usermodel.S
import org.apache.poi.ss.usermodel.W
import org.apache.poi.ss.util.CellRangeAddressL
public class CreateExcelMoBusiness {
private static String EXCEL_HIDE_SHEET_NAME = "excelhidesheetname";
private static String HIDE_SHEET_NAME_SEX = "sexList";
private static String HIDE_SHEET_NAME_PROVINCE = "provinceList";
private HashMap map = new HashMap();
//设置下拉列表的内容
private static String[] sexList = {"男","女"};
private static String[] provinceList = {"浙江","山东","江西","江苏","四川"};
private static String[] zjProvinceList = {"浙江","杭州","宁波","温州"};
private static String[] sdProvinceList = {"山东","济南","青岛","烟台"};
private static String[] jxProvinceList = {"江西","南昌","新余","鹰潭","抚州"};
private static String[] jsProvinceList = {"江苏","南京","苏州","无锡"};
private static String[] scProvinceList = {"四川","成都","绵阳","自贡"};
public static void main(String[] args) {
//使用事例
Workbook wb = new HSSFWorkbook();
createExcelMo(wb);
creatExcelHidePage(wb);
setDataValidation(wb);
FileOutputStream fileO
fileOut = new FileOutputStream("d://excel_template.xls");
wb.write(fileOut);
fileOut.close();
} catch (Exception e) {
e.printStackTrace();
public static void
createExcelMo(Workbook wb){
Sheet sheet = wb.createSheet("用户分类添加批导");
// Create a row and put some cells in it. Rows are 0 based.
Row row = sheet.createRow(0);
Cell cell = row.createCell(0);
cell.setCellValue("手机号码");
cell.setCellStyle(getTitleStyle(wb));
cell = row.createCell(1);
cell.setCellValue("所属父类");
cell.setCellStyle(getTitleStyle(wb));
cell = row.createCell(2);
cell.setCellValue("所属子类");
cell.setCellStyle(getTitleStyle(wb));
cell = row.createCell(3);
* 设置模板文件的横向表头单元格的样式
* @param wb
private static CellStyle getTitleStyle(Workbook wb){
CellStyle style = wb.createCellStyle();
//对齐方式设置
style.setAlignment(CellStyle.ALIGN_CENTER);
//边框颜色和宽度设置
style.setBorderBottom(CellStyle.BORDER_THIN);
style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
style.setBorderLeft(CellStyle.BORDER_THIN);
style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
style.setBorderRight(CellStyle.BORDER_THIN);
style.setRightBorderColor(IndexedColors.BLACK.getIndex());
style.setBorderTop(CellStyle.BORDER_THIN);
style.setTopBorderColor(IndexedColors.BLACK.getIndex());
style.setFillBackgroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
//设置背景颜色
style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
//粗体字设置
Font font = wb.createFont();
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
style.setFont(font);
* 设置模板文件的横向表头单元格的样式
* @param wb
public static void creatExcelHidePage(Workbook workbook){
Sheet hideInfoSheet = workbook.createSheet(EXCEL_HIDE_SHEET_NAME);//隐藏一些信息
//在隐藏页设置选择信息
//第一行设置性别信息
Row sexRow = hideInfoSheet.createRow(0);
creatRow(sexRow, sexList);
//第二行设置省份名称列表
Row provinceNameRow = hideInfoSheet.createRow(1);
creatRow(provinceNameRow, provinceList);
//以下行设置城市名称列表
Row cityNameRow = hideInfoSheet.createRow(2);
creatRow(cityNameRow, zjProvinceList);
cityNameRow = hideInfoSheet.createRow(3);
creatRow(cityNameRow, sdProvinceList);
cityNameRow = hideInfoSheet.createRow(4);
creatRow(cityNameRow, jxProvinceList);
cityNameRow = hideInfoSheet.createRow(5);
creatRow(cityNameRow, jsProvinceList);
cityNameRow = hideInfoSheet.createRow(6);
creatRow(cityNameRow, scProvinceList);
//名称管理
//第一行设置性别信息
creatExcelNameList(workbook, HIDE_SHEET_NAME_SEX, 1, sexList.length, false);
//第二行设置省份名称列表
creatExcelNameList(workbook, HIDE_SHEET_NAME_PROVINCE, 2, provinceList.length, false);
//以后动态大小设置省份对应的城市列表
creatExcelNameList(workbook, provinceList[0], 3, zjProvinceList.length, true);
creatExcelNameList(workbook, provinceList[1], 4, sdProvinceList.length, true);
creatExcelNameList(workbook, provinceList[2], 5, jxProvinceList.length, true);
creatExcelNameList(workbook, provinceList[3], 6, jsProvinceList.length, true);
creatExcelNameList(workbook, provinceList[4], 7, scProvinceList.length, true);
//设置隐藏页标志
workbook.setSheetHidden(workbook.getSheetIndex(EXCEL_HIDE_SHEET_NAME), true);
* 创建一个名称
* @param workbook
private static void creatExcelNameList(Workbook workbook,String nameCode,int order,int size,boolean cascadeFlag){
name = workbook.createName();
name.setNameName(nameCode);
name.setRefersToFormula(EXCEL_HIDE_SHEET_NAME+"!"+creatExcelNameList(order,size,cascadeFlag));
* 名称数据行列计算表达式
* @param workbook
private static String creatExcelNameList(int order,int size,boolean cascadeFlag){
char start = 'A';
if(cascadeFlag){
start = 'B';
if(size&=25){
char end = (char)(start+size-1);
return "$"+start+"$"+order+":$"+end+"$"+
char endPrefix = 'A';
char endSuffix = 'A';
if((size-25)/26==0||size==51){//26-51之间,包括边界(仅两次字母表计算)
if((size-25)%26==0){//边界值
endSuffix = (char)('A'+25);
endSuffix = (char)('A'+(size-25)%26-1);
}else{//51以上
if((size-25)%26==0){
endSuffix = (char)('A'+25);
endPrefix = (char)(endPrefix + (size-25)/26 - 1);
endSuffix = (char)('A'+(size-25)%26-1);
endPrefix = (char)(endPrefix + (size-25)/26);
return "$"+start+"$"+order+":$"+endPrefix+endSuffix+"$"+
if(size&=26){
char end = (char)(start+size-1);
return "$"+start+"$"+order+":$"+end+"$"+
char endPrefix = 'A';
char endSuffix = 'A';
if(size%26==0){
endSuffix = (char)('A'+25);
if(size&52&&size/26&0){
endPrefix = (char)(endPrefix + size/26-2);
endSuffix = (char)('A'+size%26-1);
if(size&52&&size/26&0){
endPrefix = (char)(endPrefix + size/26-1);
return "$"+start+"$"+order+":$"+endPrefix+endSuffix+"$"+
* 创建一列数据
* @param currentRow
* @param textList
private static void creatRow(Row currentRow,String[] textList){
if(textList!=null&&textList.length&0){
int i = 0;
for(String cellValue : textList){
Cell userNameLableCell = currentRow.createCell(i++);
userNameLableCell.setCellValue(cellValue);
* 添加数据验证选项
* @param sheet
public static void setDataValidation(Workbook wb){
int sheetIndex = wb.getNumberOfSheets();
if(sheetIndex&0){
for(int i=0;i&sheetIi++){
Sheet sheet = wb.getSheetAt(i);
if(!EXCEL_HIDE_SHEET_NAME.equals(sheet.getSheetName())){
DataValidation data_validation_list =
//省份选项添加验证数据
for(int a=2;a&3002;a++){
data_validation_list = getDataValidationByFormula(HIDE_SHEET_NAME_PROVINCE,a,2);
sheet.addValidationData(data_validation_list);
//城市选项添加验证数据
data_validation_list = getDataValidationByFormula("INDIRECT(B"+a+")",a,3);
sheet.addValidationData(data_validation_list);
//性别添加验证数据
data_validation_list = getDataValidationByFormula(HIDE_SHEET_NAME_SEX,a,1);
sheet.addValidationData(data_validation_list);
* 使用已定义的数据源方式设置一个数据验证
* @param formulaString
* @param naturalRowIndex
* @param naturalColumnIndex
private static DataValidation getDataValidationByFormula(String formulaString,int naturalRowIndex,int naturalColumnIndex){
//加载下拉列表内容
DVConstraint constraint = DVConstraint.createFormulaListConstraint(formulaString);
//设置数据有效性加载在哪个单元格上。
//四个参数分别是:起始行、终止行、起始列、终止列
int firstRow = naturalRowIndex-1;
int lastRow = naturalRowIndex-1;
int firstCol = naturalColumnIndex-1;
int lastCol = naturalColumnIndex-1;
CellRangeAddressList regions=new CellRangeAddressList(firstRow,lastRow,firstCol,lastCol);
//数据有效性对象
DataValidation data_validation_list = new HSSFDataValidation(regions,constraint);
//设置输入信息提示信息
data_validation_list.createPromptBox("下拉选择提示","请使用下拉方式选择合适的值!");
//设置输入错误提示信息
data_validation_list.createErrorBox("选择错误提示","你输入的值未在备选列表中,请下拉选择合适的值!");
return data_validation_
private static DataValidation getDataValidationByDate(int naturalRowIndex,int naturalColumnIndex){
//加载下拉列表内容
DVConstraint constraint = DVConstraint.createDateConstraint(DVConstraint.OperatorType.BETWEEN,"", "", "yyyy-mm-dd");
//设置数据有效性加载在哪个单元格上。
//四个参数分别是:起始行、终止行、起始列、终止列
int firstRow = naturalRowIndex-1;
int lastRow = naturalRowIndex-1;
int firstCol = naturalColumnIndex-1;
int lastCol = naturalColumnIndex-1;
CellRangeAddressList regions=new CellRangeAddressList(firstRow,lastRow,firstCol,lastCol);
//数据有效性对象
DataValidation data_validation_list = new HSSFDataValidation(regions,constraint);
//设置输入信息提示信息
data_validation_list.createPromptBox("日期格式提示","请按照'yyyy-mm-dd'格式输入日期值!");
//设置输入错误提示信息
data_validation_list.createErrorBox("日期格式错误提示","你输入的日期格式不符合'yyyy-mm-dd'格式规范,请重新输入!");
return data_validation_
该示例参考了网上的代码,只是把代码整合在了一起,添加了可测试的main方法方便测试,以便没有成功实现联动的朋友只要把类拷贝到自己的工程里并引入需要的包就能直接看到效果。生成的EXCEL文件放在D盘根目录。
参考的版本 poi3.7
下载请到下载最新版本
个人博客:
浏览: 19484 次
来自: 福建
您好,请教个问题 您这款导出
在excel2003上看没有问 ...
我原封不动的执行了代码,“所属父类”选择的情况下,“所属子类” ...
,我试了n级联动都可以的,一楼再试试,差点误导我
这里面才是俩级关联。。如果是多级关联怎么做啊~~有例子吗~~想 ...
(window.slotbydup=window.slotbydup || []).push({
id: '4773203',
container: s,
size: '200,200',
display: 'inlay-fix'java中,JComboBox下拉框选项事件。比如我选择一个,怎么返回相应的事件_百度知道
java中,JComboBox下拉框选项事件。比如我选择一个,怎么返回相应的事件
能给个例子最好...
能给个例子最好
答题抽奖
首次认真答题后
即可获得3次抽奖机会,100%中奖。
来自电脑网络类芝麻团
采纳数:125
获赞数:599
参与团队:
选中事件:&JComboBox&String&&comboBox_4&=&new&JComboBox&String&();&comboBox_4.setBounds(199,&117,&35,&22);&&panel_2.add(comboBox_4);&//这是父容器&&comboBox_4.addItem(&1&);//添加元素&&comboBox_4.addItem(&2&);&&comboBox_4.addItem(&3&);&//监听选中&&&comboBox_4.addItemListener(new&ItemListener()&&{&&&@Override&&&public&void&itemStateChanged(ItemEvent&e)&&&{//如果选中了一个&&&&&if&(e.getStateChange()&==&ItemEvent.SELECTED)&{&//这里写你的任务&,比如取到现在的值&&String&text=(String)&comboBox_4.getSelectedItem();&&}&&&}&&});
采纳数:183
获赞数:297
用combobox的onSelect来触发事件应该就可以了吧
没有这个方法吧?你可以给个例子吗?
sorry,我看错了,给你找了篇博文,你看看是不是你要找的
本回答被提问者采纳
1条折叠回答
为你推荐:
其他类似问题
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。先锋游戏知道信息频道欢迎您
编程:java Html中如何将两个下拉列表框绑定,
[王二小] [ 14:31:31] (<span id="tgd) (<span id="tfd) &&
问题详情最佳答案字太多给你发个图片其他答案地址都是存数据库的么?
那网上很多这样的
自己去看看吧
下载要积分
别人都做好了,,你直接看源码,不就可以了,,哎,真着急啊
我并没有看到复选框和里面值的代码
你是新手么?他肯定引了js,把js复制出来,,就可以了,,他那个就是demo,你要看他是怎么写的
昵称: 验证码:
评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述
编程相关知识
编程其他问题java下拉列表更新
[问题点数:20分,结帖人yzyz0812]
本版专家分:0
结帖率 85.71%
CSDN今日推荐
本版专家分:26587
本版专家分:0
本版专家分:0
本版专家分:67
本版专家分:70
匿名用户不能发表回复!
其他相关推荐用java,jsp和javascript写的分页及有下拉列表分页的功能
我的图书馆
用java,jsp和javascript写的分页及有下拉列表分页的功能
& & &页面dubietyPosition.jsp:
Java代码 &&%@&page&language="java"&contentType="text/&charset=GBK"&%&&&&%@&page&import="...weihu.vo.DubietyPosition"&%&&&&%@&page&import="...weihu.dao.DubietyPositionDao"&%&&&&%@&page&import="...weihu.util.Page"&%&&&&%@&page&import="java.util.List"&%&&&&%@&page&import="java.util.Iterator"&%&&&&%@&page&import="....util.Log"&%&&&&&&%&&//从...weihu.DubietyPositionDao获得数据库的相关操作&&DubietyPositionDao&dpDao=&&//显示的内容&&List&listDP=&&//用于做分页&&Page&page1=&&[b]try{&&&&&page1=new&Page();&&&&&dpDao=page1.getDao();&&&&&String&currentPageNo=request.getParameter("currentPageNo");&&&&&if(currentPageNo!=null){&&&&&&&&&page1.refresh(Integer.parseInt(currentPageNo));&&&&&}&&&&&&&&String&pageMethod=request.getParameter("pageMethod");&&&&&if(pageMethod!=null){&&&&&&&&&if(pageMethod.equals("first")){&&&&&&&&&&&&page1.first();&&&&&&&&&}else&if(pageMethod.equals("last")){&&&&&&&&&&&&page1.last();&&&&&&&&&}&&&&&}&&&&&listDP=page1.getCurrentPage(page1.getCurrentPageNo(),page1.getPageSize());&&&&}catch(Exception&e){&&&&&Log.error(this,&"dubietyPosition.jsp",&e.getMessage());&&}[/b]&&//记录编号&&int&i=(page1.getCurrentPageNo()-1)*page1.getPageSize()+1;&&&&%&&&&&&!DOCTYPE&HTML&PUBLIC&"-//W3C//DTD&HTML&4.01&Transitional//EN"&&&&html&&&&&&head&&&&meta&http-equiv="Content-Type"&content="text/&charset=gb2312"&&&&&&style&&&&&&/style&&&&link&href="/include/WeiHuCSS.css"&rel="stylesheet"&type="text/css"&&&&&&jsp:include&page="/public/_nocache.jsp"&flush="true"&/&&&&jsp:include&page="/public/_head.jsp"&flush="true"&/&&&&title&可疑职位信息筛选&/title&&&...&&&&&script&type="text/javascript"&&&[b]&!--&控制下拉列表的值&--&&&&&function&vaildate()&&&{&&&&&&&&&&&//var&getselect=document.thisForm2.currentPageNo.&&&&&&&&&&//&document.thisForm2.val.value=&&&&&&&&&&//&document.thisForm1.submit();&&//这样写是提交&&&&&&&//下面是个连接&&&&&&&window.location.href&=&"/weihu/Server/dubietyPosition.jsp?currentPageNo="&+&document.thisForm1.currentPageNo.&&&}&&&&/script&[/b]&&&/head&&&&&&&&&body&bgcolor="#E6E6E6"&leftmargin="0"&topmargin="0"&&&&&&&&&table&width="759"&border="0"&align="center"&cellpadding="0"&cellspacing="0"&bgcolor="#FFFFFF"&&&&&&&&&&&tr&&&&&&&&td&&&&&&&&&&&%@include&file="/weihu/inc/serve.jsp"%&&&&&&&&&&&&&&table&width="759"&border="0"&align="center"&cellpadding="0"&cellspacing="0"&&&&&&&&&&&&tr&&&&&&&&&&&&&&td&height="1"&bgcolor="#F4F4F4"&&/td&&&&&&&&&&&&/tr&&&&&&&&&&&&tr&&&&&&&&&&&&&&td&height="23"&bgcolor="#E5EAEF"&class="td2"&&&&&&&&&&&&&&font&color="#7B7B7B"&&strong&&&&&&&&&&&&&&&&&&&p&style="margin-top:3px"&&您所在的位置:客户服务部&&&可疑职位信息筛选&/p&&/strong&&/font&&&&&&&&&&&&&&/td&&&&&&&&&&&&/tr&&&&&&&&&&&&&&/table&&&&&&&&&&form&name="thisForm1"&method="post"&action="dubietyPosition.jsp?currentPageNo=&%=page1.getCurrentPageNo()&%&"&&&&&&&&&&table&border="0"&cellpadding="0"&cellspacing="2"&align="center"width="100%"&&&&&&&&tr&&&&&&&&&&td&colspan="7"&class="left"&同时显示职位摘要信息&input&type="checkbox"&onclick="toggleAll(this);"&checked="checked"/&&/td&&&&&&&&/tr&&&&&&&&tr&&&&&&&&&&&&&&&&&th&width="5%"&序号&/th&&&&&&&&&&&&&&&&&th&width="20%"&招聘职位&/th&&&&&&&&&&&&th&width="35%"&企业名称&/th&&&&&&&&&&&&th&width="12%"&工作地区&/th&&&&&&&&&&&&th&width="10%"&最低学历&/th&&&&&&&&&&&&th&width="10%"&工作经验&/th&&&&&&&&&&&&th&width="8%"&选择&/th&&&&&&&&/tr&&&&&&&&%if(listDP!=null){&%&&&&&&&&&&&&&&&&&&&&&&&&%Iterator&it=listDP.iterator();&&&&&&&&&&while(it.hasNext()){&&&&&&&&&&&&&&&&&&DubietyPosition&dp=(DubietyPosition)it1.next();&&&&&&%&&&&&&&&tr&class="tr&%=(i+1)%2%&"&&&&&&&&&&&td&&b&&%=i++&%&&/b&&&/td&&&&&&&&&&&td&class="left"&&%=dp.getPosname()&%&&/td&&&&&&&&&&&td&class="left"&&%=dp.getComname()&%&&&/td&&&&&&&&&&&td&&%=dp.getAddress()&%&&/td&&&&&&&&&&&td&&%=dp.getReqDegreeName()&%&&/td&&&&&&&&&&td&&%if(dp.getReqWorkYear()==-100)&{%&不限&&&&&&&%}else{&%&&&&&&&&%=dp.getReqWorkYear()&%&年&&&&&&&%}&%&&&&&&&&&&&&&&&&&&&&/td&&&&&&&&&&&&td&&&&&&&&&&&&%if(dpDao.getMapPosState().get(new&Integer(dp.getPosId())).equals(new&Integer(1))){&%&&&&&&&&&&&&&&&&&&&input&type="checkbox"&value="&%=dp.getPosId()&%&"&name="posIds"&disabled="disabled"/&&&&&&&&&&&&&&&&&&&&&%}else{&%&&&&&&&input&type="checkbox"&value="&%=dp.getPosId()&%&"&name="posIds"/&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&%}&%&&&&&&&&&&&&&&&&/td&&&&&&&&&&&&&/tr&&&&&&&&tr&class="tr&%=i%2%&"&id="desc"&name="desc"&&&&&&&&td&colspan="7"&class="left"&&div&style="padding:0&15"&&&&&&&&&&&&&&&&&%=dpDao.getMap().get(new&Integer(dp.getPosId()))&%&&/div&&/td&&&&&&&&&&&&/tr&&&&&&&&&&&%&}%&&&&&&&&tr&class="right"&&&&&&&&td&colspan="7"&&&&&&&&&&&&table&&&&&&&&&&tr&&&&&&&&&&&&&&&&&td&&&&&&&&&&&&&&br/&&&&&&&&&&&&当前页为第&&%=page1.getCurrentPageNo()&%&&页,总页数为&%=page1.getTotalPages()&%&&&&%if(page1.getCurrentPageNo()!=1){%&&&&&&&&&&&&&&&&&&&&&a&href="dubietyPosition.jsp?pageMethod=first"&&u&第一页&/u&&/a&&&&&%}&if(page1.getCurrentPageNo()&1){%&&&&&&&&&&&&&&a&href="dubietyPosition.jsp?currentPageNo=&%=page1.getCurrentPageNo()-1&%&"&&u&上一页&/u&&/a&&&&%}&if(page1.getCurrentPageNo()&page1.getTotalPages()){%&&&&a&href="dubietyPosition.jsp?currentPageNo=&%=page1.getCurrentPageNo()+1&%&"&&u&下一页&/u&&/a&&&&&%}&if(page1.getCurrentPageNo()!=page1.getTotalPages()){%&&&&a&href="dubietyPosition.jsp?pageMethod=last"&&u&最后一页&/u&&/a&&&&%}&%&&&&&[b]&!--&下拉列表跳转&--&&&&&跳转到&&&&&&&&&select&name="currentPageNo"&&class="inputAndSelect"&&onchange="vaildate()"&&&&&&&&&&&&&&&&&&&&&&%for(int&k=1;k&=page1.getTotalPages();k++){&&&&&&&&&&&&&&&&&&&&&&&if(k==page1.getCurrentPageNo()){&&&&&&&&&&&&&&&&&%&&&&&&&&&&&&&option&value="&%=k&%&"&selected="selected"&&%=k&%&&/option&&&&&&&&&&&&&&&&&&&&&&&&%}&else{%&&&&&&&&&&&&&&&&&&option&value="&%=k&%&"&&%=k&%&&/option&&&&&&&&&&&&&&&&&&&&&&%}}&%&&&&&&&&&&/select&[/b]&&&&&&&&&/td&&&&&&&&&&&&&/tr&&&&&&&&/table&&br/&&&&&&&选择所有&input&type="checkbox"&onclick="selectAll(this)"/&&input&type="submit"&value="屏蔽选择的职位"&&&&&&&&&&&&&&&&&/td&&&&/tr&&&&&&&&&&&&%}else{&%&&&&&&&&&&tr&&td&colspan="7"&class="center"&没有任何数据&&/td&&&/tr&&&&%}&%&&&&/table&&&&&&&&/form&&&&&&&&jsp:include&page="../inc/footer.jsp"&flush="true"&/&&&&/td&&&&&&&&&&/tr&&&&&&&&/table&&&&&&&&&&&&/body&&&&/html&&&
Java代码 &javascript:&&&&script&type="text/javascript"&&&&&&&b&&!--&控制下拉列表的值&--&&&&&&&&&&function&vaildate()&&&{&&&&&&&&&&&&&&//var&getselect=document.thisForm2.currentPageNo.&&&&&&&&&&&&//&document.thisForm2.val.value=&&&&&&&&&&&&&//&document.thisForm1.submit();&&//这样写是提交&&&&&&&&&&//下面是个连接&&&&&&&&&&window.location.href&=&"/weihu/Server/dubietyPosition.jsp?currentPageNo="&+&document.thisForm1.currentPageNo.&&&&&}&&&&&&/script&&&
页面中对应form中的代码
Java代码 &&select&name="currentPageNo"&&class="inputAndSelect"&&onchange="vaildate()"&&&&&&&&&&&&&&&&&&&&&&&&%for(int&k=1;k&=page1.getTotalPages();k++){&&&&&&&&&&&&&&&&&&&&&&&&&&if(k==page1.getCurrentPageNo()){&&&&&&&&&&&&&&&&&&&&%&&&&&&&&&&&&&&&&option&value="&%=k&%&"&selected="selected"&&%=k&%&&/option&&&&&&&&&&&&&&&&&&&&&&&&&&%}&else{%&&&&&&&&&&&&&&&&&&&&option&value="&%=k&%&"&&%=k&%&&/option&&&&&&&&&&&&&&&&&&&&&&&&&%}}&%&&&&&&&&&&&&&/select&&/b&&&&
------------------------------------
一个工具类Page.java
Java代码 &package&com.huanglq.weihu.&&&&import&java.util.L&&&&/**&&*&用于做分页&&*&@author&huanglq&&*&&*/&&public&class&Page&{&&&&&&&&//总行数&&&&&&private&int&totalR&&&&&&&&&&&&//每页显示的记录数,这里已经事先给了20条&&&&&&private&int&pageSize=20;&&&&&&&&&&&&//当前页&&&&&&private&int&currentPageNo;&&&&&&&&&&&&//总页数&&&&&&private&int&totalP&&&&&&&&//DubietyPositionDao&&&&&&DubietyPositionDao&dao=new&DubietyPositionDao();&&&&&&//构造函数&&&&&&public&Page(){&&&&&&&&&&totalRows=dao.getTotalRows();&&&&&&&&&&if(totalRows%pageSize==0){&&&&&&&&&&&&&&totalPages=totalRows/pageS&&&&&&&&&&}else{&&&&&&&&&&&&&&totalPages=totalRows/pageSize+1;&&&&&&&&&&}&&&&&&&&&&//为防止currentPageNo出异常在这里事先给了currentPageNo=1&&&&&&&&&&currentPageNo=1;&&&&&&}&&&&&&//获得每页的记录&&&&&&public&List&getCurrentPage(int&_currentPageNo,int&_pageSize){&&&&&&&&&&return&dao.currentPage(_currentPageNo,&_pageSize);&&&&&&}&&&&&&&&&&&&//第一页&&&&&&public&void&first(){&&&&&&&&&&currentPageNo=1;&&&&&&}&&&&&&&&&&&&//最后一页&&&&&&public&void&last(){&&&&&&&&&&currentPageNo=totalP&&&&&&}&&&&&&//防止出现大于最后一页&&&&&&public&void&refresh(int&_currentPageNo){&&&&&&&&&&currentPageNo=_currentPageNo;&&&&&&&&&&if(currentPageNo&totalPages)&&&&&&&&&&&&&&last();&&&&&&}&&&&&&&&&&&&&&&&&&public&int&getTotalRows()&{&&&&&&&&&&return&totalR&&&&&&}&&&&&&&&public&void&setTotalRows(int&totalRows)&{&&&&&&&&&&this.totalRows&=&totalR&&&&&&}&&&&&&&&public&int&getPageSize()&{&&&&&&&&&&return&pageS&&&&&&}&&&&&&&&public&void&setPageSize(int&pageSize)&{&&&&&&&&&&this.pageSize&=&pageS&&&&&&}&&&&&&&&public&int&getCurrentPageNo()&{&&&&&&&&&&return&currentPageNo;&&&&&&}&&&&&&&&public&void&setCurrentPageNo(int&currentPageNo)&{&&&&&&&&&&this.currentPageNo&=&currentPageNo;&&&&&&}&&&&&&&&public&int&getTotalPages()&{&&&&&&&&&&return&totalP&&&&&&}&&&&&&&&public&void&setTotalPages(int&totalPages)&{&&&&&&&&&&this.totalPages&=&totalP&&&&&&}&&&&&&public&DubietyPositionDao&getDao()&{&&&&&&&&&&return&&&&&&&}&&&&&&public&void&setDao(DubietyPositionDao&dao)&{&&&&&&&&&&this.dao&=&&&&&&&}&&&&&&&&}&&----------------------
dao的DubietyPositionDao类的分页内容的写法1:用resultset分页
Java代码 &//pageSize页面大小,totalRows总行数&&&&&&public&List&getDPCurrentPage(int&currentPageNo,&int&pageSize){&&&&&&&&&&List&listDP=&&&&&&&&&&Connection&conn&=&&&&&&&&&&&PreparedStatement&pstmt&=&&&&&&&&&&&ResultSet&rs&=&&&&&&&&&&&//用于计算页面的start&&&&&&&&&&int&total&=&currentPageNo&*&pageS&&&&&&&&&&//每页的开始行数&&&&&&&&&&int&start&=&total&-&pageSize&+&1;&&&&&&&&&&&&&&&&&&&&String&sql="select&Top&"+total+"&posid,comname,posname,address_pc,reqDegreeName,reqworkyear&"&&&&&&&&&&+"from&huanglq_query..compos_query&where&contains(comname,'"+COMNAMES+"')&"&&&&&&&&&&+"and&contains(posname,'"+POSNAMES+"')";&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&try&{&&&&&&&&&&&&&&conn&=&DBUtil.getHuanglqQueryConn();&&&&&&&&&&&&&&pstmt&=&conn.prepareStatement(sql,&&&&&&&&&&&&&&&&&&&&&&ResultSet.TYPE_SCROLL_INSENSITIVE,//该常量指示可滚动但通常不受其他的更改影响的&ResultSet&对象的类型。&&&&&&&&&&&&&&&&&&&&&&ResultSet.CONCUR_READ_ONLY);//该常量指示不可以更新的&ResultSet&对象的并发模式&&&&&&&&&&&&&&&&&&&&&&&&&&&&rs&=&pstmt.executeQuery();&&&&&&&&&&&&&&&&Log.debug(this,&"getDPCurrentPage(int&currentPageNo,&int&pageSize)",&sql.toString());&&&&&&&&&&&&&&&&if&(rs.absolute(start))&{//rs指向当前页的开始行&&&&&&&&&&&&&&&&&&listDP&=&new&ArrayList();&&&&&&&&&&&&&&&&&&while&(rs.getRow()&&=&total)&{&&&&&&&&&&&&&&&&&&&&&&DubietyPosition&dp&=&new&DubietyPosition();&&&&&&&&&&&&&&&&&&&&&&dp.setPosId(rs.getInt("posid"));&&&&&&&&&&&&&&&&&&&&&&dp.setComname(rs.getString("comname"));&&&&&&&&&&&&&&&&&&&&&&dp.setPosname(rs.getString("posname"));&&&&&&&&&&&&&&&&&&&&&&dp.setAddress(rs.getString("address_pc"));&&&&&&&&&&&&&&&&&&&&&&dp.setReqWorkYear(rs.getInt("reqworkyear"));&&&&&&&&&&&&&&&&&&&&&&dp.setReqDegreeName(rs.getString("reqDegreeName"));&&&&&&&&&&&&&&&&&&&&&&//&把可疑职位添加到可疑职位列表中&&&&&&&&&&&&&&&&&&&&&&listDP.add(dp);&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&/*&&&&&&&&&&&&&&&&&&&&&&*&rs.nect()的作用是使rs.getRow()每次都加1,还有当页面不足要求的记录时可以跳出循环,防止null异常&&&&&&&&&&&&&&&&&&&&&&*/&&&&&&&&&&&&&&&&&&&&&&if&(!rs.next())&{&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&}&&&&&&&&&&&&&&&&&&}&&&&&&&&&&&&&&}&&&&&&&&&&}&catch&(Exception&e)&{&&&&&&&&&&&&&&Log.error(this,&"getDPCurrentPage(int&currentPageNo,&int&pageSize)",&e.getMessage());&&&&&&&&&&}&finally&{&&&&&&&&&&&&&&DBUtil.clean(this,&rs);&&&&&&&&&&&&&&DBUtil.clean(this,&pstmt);&&&&&&&&&&&&&&DBUtil.clean(this,&conn);&&&&&&&&&&}&&&&&&&&&&return&listDP;&&&&&&}&&dao的DubietyPositionDao类的分页内容的写法2:用sql语句传参分页
Java代码 &public&List&currentPage(int&currentPageNo,&int&pageSize)&{&&&&&&List&listDP&=&new&ArrayList();//&可疑职位列表&&&&&&&Connection&conn&=&&&&&&&PreparedStatement&pstmt&=&&&&&&&ResultSet&rs&=&&&&&&&&&int&pageNo&=&(currentPageNo&-&1)&*&pageS&&&&&&int&pSize&=&pageS&&&&&&//&分页查询语句&&&&&&String&sql&=&"select&Top&"+&pSize+&"&posid,comname,posname,address_pc,reqDegreeName,reqworkyear&from&huagnlq_query..compos_query&where&posid&not&in&"&+&"(&select&Top&"+&pageNo+&"&posid&from&huanglq_query..compos_query&order&by&inserttime&desc)&&order&by&inserttime&desc";&&&&&&&&try&{&&&&&&&&&&conn&=&DBUtil.getHuanglqQueryConn();&&&&&&&&&&pstmt&=&conn.prepareStatement(sql);&&&&&&&&&&rs&=&pstmt.executeQuery();&&&&&&&&&&while&(rs.next())&{&&&&&&&&&&&&&&&DubietyPosition&dp&=&new&DubietyPosition();&&&&&&&&&&dp.setPosId(rs.getInt("posid"));&&&&&&&&&&dp.setComname(rs.getString("comname"));&&&&&&&&&&dp.setPosname(rs.getString("posname"));&&&&&&&&&&dp.setAddress(rs.getString("address_pc"));&&&&&&&&&&dp.setReqWorkYear(rs.getInt("reqworkyear"));&&&&&&&&&&&&&&dp.setReqDegreeName(rs.getString("reqDegreeName"));&&&&&&&&&&//&把可疑职位添加到可疑职位列表中&&&&&&&&&&listDP.add(dp);&&&&&&&&&&}&&&&&&}&catch&(Exception&e)&{&&&&&&&&&&e.printStackTrace();&&&&&&}&finally&{&&&&&&&&&&DBUtil.clean(listDP,&rs);&&&&&&&&&&DBUtil.clean(listDP,&pstmt);&&&&&&&&&&DBUtil.clean(listDP,&conn);&&&&&&}&&&&&&return&listDP;&&&&&&}&&DubietyPositionDao.java
Java代码 &package&com.huanglq.weihu.&&&&/**&&*&这是一个装载可疑职位的类的Dao&&*&这里涉及和两个数据库huanglw_query..compos_query和[huanglq].[dbo].[com_Position]&&*/&&import&java.sql.C&&import&java.sql.PreparedS&&import&java.sql.ResultS&&import&java.sql.S&&import&java.util.ArrayL&&import&java.util.HashM&&import&java.util.L&&import&java.util.M&&import&java.util.D&&&&import&com.huanglq.message.M&&import&com.huanglq.util.DBU&&import&com.huanglq.util.DateT&&import&com.huanglq.util.L&&&&public&class&DubietyPositionDao&{&&&&&&&&&&&&//公司名包含的字段&&&&&&public&static&final&String[]&COMNAME_CONTAINS&=&{"娱乐","俱乐部","酒店","会所","休闲","夜总会","贵族","酒城"};&&&&&&&&&&&&//职位包含的字段&&&&&&public&static&final&String[]&POSNAME_CONTAINS&=&{"dj","服务员","特陪","特服生","接待","公关","陪","服务生",&&&&&&&&&&"少爷","公主","伴游","特服生","私人","接待","夜总会","桑拿"};&&&&&&//公司名包含的字段转换后的字段&&&&&&public&static&String&COMNAMES="";&&&&&&//职位包含的字段转换后的字段&&&&&&public&static&String&POSNAMES="";&&&&&&&&&&&&//用静态初始化块来初始化COMNAMES和POSNAMES&&&&&&static&{&&&&&&&&&&for(int&i=0;i&COMNAME_CONTAINS.i++){&&&&&&&&&&&&&&COMNAMES=COMNAMES+COMNAME_CONTAINS[i]+"&or&";&&&&&&&&&&}&&&&&&&&&&COMNAMES&=&COMNAMES.substring(0,&COMNAMES.length()&-&4);&&&&&&&&&&&&&&&&&&&&for(int&i=0;i&POSNAME_CONTAINS.i++){&&&&&&&&&&&&&&POSNAMES=POSNAMES+POSNAME_CONTAINS[i]+"&or&";&&&&&&&&&&}&&&&&&&&&&POSNAMES&=&POSNAMES.substring(0,&POSNAMES.length()&-&4);&&&&&&}&&&&&&&&&&&&//用于查询获得可疑职位总记录数的sql语句&&&&&&public&static&final&String&TOTALSIZE_SQL="select&count(*)&from&huauglq_query..compos_query&where&contains&"&+&&&&&&&&&&&&&&"(comname,'"+COMNAMES+"')&and&&contains(posname,'"+POSNAMES+"')";&&&&&&&&&&&&//&用来存储posid和其posDescription,map(posid,posDescription)&&&&&&private&Map&map&=&new&HashMap();&&&&&&//&用来存储posid和其posState,map(posid,posState)&&&&&&private&Map&mapPosState&=&new&HashMap();&&&&&&&&//&数据库是huanglq_query..compos_query&&&&&&//&获得可疑职位总记录数&&&&&&public&int&getTotalRows()&{&&&&&&&&&&int&totalRows&=&0;&&&&&&&&&&Connection&conn&=&&&&&&&&&&&PreparedStatement&pstmt&=&&&&&&&&&&&ResultSet&rs&=&&&&&&&&&&&&&try&{&&&&&&&&&&&&&&conn&=&DBUtil.getHuanglqQueryConn();&&&&&&&&&&&&&&pstmt&=&conn.prepareStatement(TOTALSIZE_SQL);&&&&&&&&&&&&&&rs&=&pstmt.executeQuery();&&&&&&&&&&&&&&while&(rs.next())&{&&&&&&&&&&&&&&&&&&totalRows&=&rs.getInt(1);&&&&&&&&&&&&&&}&&&&&&&&&&&&&&Log.debug(this,&"DubietyPositionDao.getTotalRows()",&TOTALSIZE_SQL);&&&&&&&&&&}&catch&(Exception&e)&{&&&&&&&&&&&&&&Log.error(this,&"DubietyPositionDao.getTotalRows()",&e.getMessage());&&&&&&&&&&}&finally&{&&&&&&&&&&&&&&DBUtil.clean(this,&rs);&&&&&&&&&&&&&&DBUtil.clean(this,&pstmt);&&&&&&&&&&&&&&DBUtil.clean(this,&conn);&&&&&&&&&&}&&&&&&&&&&return&totalR&&&&&&}&&&&&&&&//&数据库是huanglq_query..compos_query&&&&&&//&按页查找可疑记录,用于做分页&&&&&&public&List&currentPage(int&currentPageNo,&int&pageSize)&{&&&&&&&&&&List&listDP&=&new&ArrayList();//&可疑职位列表&&&&&&&&&&&&&&&&&&&&long&startTime=new&Date().getTime();&&&&&&&&&&&&&&&&&&&&Connection&conn&=&&&&&&&&&&&PreparedStatement&pstmt&=&&&&&&&&&&&ResultSet&rs&=&&&&&&&&&&&&&int&pageNo&=&(currentPageNo&-&1)&*&pageS&&&&&&&&&&int&pSize&=&pageS&&&&&&&&&&//&分页查询语句&&&&&&&&&&String&sql&=&"select&Top&"&&&&&&&&&&&&&&&&&&+&pSize&&&&&&&&&&&&&&&&&&+&"&posid,comname,posname,address_pc,reqDegreeName,reqworkyear&from&huanglq_query..compos_query&where&posid&not&in&"&&&&&&&&&&&&&&&&&&+&"(&select&Top&"&&&&&&&&&&&&&&&&&&+&pageNo&&&&&&&&&&&&&&&&&&+&"&posid&from&huanglq_query..compos_query&"&&&&&&&&&&&&&&&&&&+&"where&contains(comname,'"+COMNAMES+"')&"&&&&&&&&&&&&&&&&&&+&"and&contains(posname,'"+POSNAMES+"')&order&by&inserttime&desc)&"&&&&&&&&&&&&&&&&&&+&"and&contains(comname,'"+COMNAMES+"')"&&&&&&&&&&&&&&&&&&+&"&and&contains(posname,'"+POSNAMES+"')&order&by&inserttime&desc";&&&&&&&&&&&&try&{&&&&&&&&&&&&&&conn&=&DBUtil.getHuanglqQueryConn();&&&&&&&&&&&&&&pstmt&=&conn.prepareStatement(sql);&&&&&&&&&&&&&&rs&=&pstmt.executeQuery();&&&&&&&&&&&&&&while&(rs.next())&{&&&&&&&&&&&&&&&&&&DubietyPosition&dp&=&new&DubietyPosition();&&&&&&&&&&&&&&&&&&dp.setPosId(rs.getInt("posid"));&&&&&&&&&&&&&&&&&&dp.setComname(rs.getString("comname"));&&&&&&&&&&&&&&&&&&dp.setPosname(rs.getString("posname"));&&&&&&&&&&&&&&&&&&dp.setAddress(rs.getString("address_pc"));&&&&&&&&&&&&&&&&&&dp.setReqWorkYear(rs.getInt("reqworkyear"));&&&&&&&&&&&&&&&&&&dp.setReqDegreeName(rs.getString("reqDegreeName"));&&&&&&&&&&&&&&&&&&//&把可疑职位添加到可疑职位列表中&&&&&&&&&&&&&&&&&&listDP.add(dp);&&&&&&&&&&&&&&}&&&&&&&&&&&&&&Log.debug(this,&"DubietyPositionDao.currentPage(int&currentPageNo,&int&pageSize)",&sql);&&&&&&&&&&}&catch&(Exception&e)&{&&&&&&&&&&&&&&Log.error(this,&"DubietyPositionDao.currentPage(int&currentPageNo,&int&pageSize)",&e.getMessage());&&&&&&&&&&}&finally&{&&&&&&&&&&&&&&DBUtil.clean(listDP,&rs);&&&&&&&&&&&&&&DBUtil.clean(listDP,&pstmt);&&&&&&&&&&&&&&DBUtil.clean(listDP,&conn);&&&&&&&&&&}&&&&&&&&&&long&endTime=new&Date().getTime();&&&&&&&&&&System.out.println(endTime-startTime+"&***************************");&&&&&&&&&&return&listDP;&&&&&&}&&&&&&&&//&数据库是[huanglq].[dbo].[com_Position]&&&&&&//&根据posid来修改可疑职位,把可疑记录的状态改为屏蔽,&&&&&&//&--PosState&0=删除,1=屏蔽,2=正常&&&&&&public&void&modifyPosState(int&posid)&{&&&&&&&&&&Connection&conn&=&&&&&&&&&&&PreparedStatement&pstmt&=&&&&&&&&&&&//提交后把posState改为1&&&&&&&&&&String&sql&=&"UPDATE&[huanglq].[dbo].[com_Position]&SET&PosState&=1,UpdateDate=getDate()&WHERE&posId=?";&&&&&&&&&&try&{&&&&&&&&&&&&&&conn&=&DBUtil.getHuanglq90Conn();&&&&&&&&&&&&&&pstmt&=&conn.prepareStatement(sql);&&&&&&&&&&&&&&pstmt.setInt(1,&posid);&&&&&&&&&&&&&&pstmt.execute();&&&&&&&&&&&&&&Log.debug(this,&"DubietyPositionDao.modifyPosState(int&posid)",&sql);&&&&&&&&&&}&catch&(Exception&e)&{&&&&&&&&&&&&&&Log.error(this,&"DubietyPositionDao.modifyPosState(int&posid)",&e.getMessage());&&&&&&&&&&}&finally&{&&&&&&&&&&&&&&DBUtil.clean(this,&pstmt);&&&&&&&&&&&&&&DBUtil.clean(this,&conn);&&&&&&&&&&}&&&&&&}&&&&&&&&//&数据库是[huanglq].[dbo].[com_Position]&&&&&&//&根据posid来查找可疑职位的摘要信息,用map来存放&&&&&&//&这里目的是可以减少对数据库的频繁操作,这里只操作一次&&&&&&//&--PosState&0=删除,1=屏蔽,2=正常&&&&&&//&根据posStatus=1来找posid把checkbox的disabled="disabled"填上&&&&&&//&mapPosState保存mapPosState(posid,posStatus),map保存map(posid,posDescription)&&&&&&//posids是一个经过转换格式的posid集合&&&&&&public&void&getPosDescAndState(String&posids)&{&&&&&&&&&&Connection&conn&=&&&&&&&&&&&Statement&pstmt&=&&&&&&&&&&&ResultSet&rs&=&&&&&&&&&&&String&sql&=&"select&posid,posDescription,posState&from&[huanglq].[dbo].[com_Position]&WHERE&posID&in(";&&&&&&&&&&try&{&&&&&&&&&&&&&&conn&=&DBUtil.getHuanglqConn();&&&&&&&&&&&&&&pstmt&=&conn.createStatement();&&&&&&&&&&&&&&rs&=&pstmt.executeQuery(sql&+&posids&+&")");&&&&&&&&&&&&&&while&(rs.next())&{&&&&&&&&&&&&&&&&&&Integer&posId&=&new&Integer(rs.getInt("posid"));&&&&&&&&&&&&&&&&&&String&posDescription&=&"";&&&&&&&&&&&&&&&&&&try&{&&&&&&&&&&&&&&&&&&&&&&posDescription&=&rs.getString("posDescription");&&&&&&&&&&&&&&&&&&}&catch&(Exception&e)&{&&&&&&&&&&&&&&&&&&&&&&posDescription&=&"暂时还没有输入数据";&&&&&&&&&&&&&&&&&&}&&&&&&&&&&&&&&&&&&map.put(posId,&posDescription);&&&&&&&&&&&&&&&&&&mapPosState.put(posId,&new&Integer(rs.getInt("posState")));&&&&&&&&&&&&&&}&&&&&&&&&&&&&&Log.debug(this,&"DubietyPositionDao.getPosDescAndState(String&posids)",&sql);&&&&&&&&&&}&catch&(Exception&e)&{&&&&&&&&&&&&&&Log.error(this,&"DubietyPositionDao.getPosDescAndState(String&posids)",&e.getMessage());&&&&&&&&&&}&finally&{&&&&&&&&&&&&&&DBUtil.clean(this,&rs);&&&&&&&&&&&&&&DBUtil.clean(this,&pstmt);&&&&&&&&&&&&&&DBUtil.clean(this,&conn);&&&&&&&&&&}&&&&&&}&&&&&&&&public&Map&getMap()&{&&&&&&&&&&return&&&&&&&}&&&&&&&&public&void&setMap(Map&map)&{&&&&&&&&&&this.map&=&&&&&&&}&&&&&&&&public&Map&getMapPosState()&{&&&&&&&&&&return&mapPosS&&&&&&}&&&&&&&&public&void&setMapPosState(Map&mapPosState)&{&&&&&&&&&&this.mapPosState&=&mapPosS&&&&&&}&&&&&&&&&&&&//分页方法2,这个比较快&&&&&&//pageSize页面大小,totalRows总行数&&&&&&public&List&getDPCurrentPage(int&currentPageNo,&int&pageSize){&&&&&&&&&&List&listDP=&&&&&&&&&&Connection&conn&=&&&&&&&&&&&PreparedStatement&pstmt&=&&&&&&&&&&&ResultSet&rs&=&&&&&&&&&&&//用于计算页面的start&&&&&&&&&&int&total&=&currentPageNo&*&pageS&&&&&&&&&&//每页的开始行数&&&&&&&&&&int&start&=&total&-&pageSize&+&1;&&&&&&&&&&&&&&&&&&&&String&sql="select&Top&"+total+"&posid,comname,posname,address_pc,reqDegreeName,reqworkyear&"&&&&&&&&&&+"from&huanglq_query..compos_query&where&contains(comname,'"+COMNAMES+"')&"&&&&&&&&&&+"and&contains(posname,'"+POSNAMES+"')";&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&try&{&&&&&&&&&&&&&&conn&=&DBUtil.getHuanglqQueryConn();&&&&&&&&&&&&&&pstmt&=&conn.prepareStatement(sql,&&&&&&&&&&&&&&&&&&&&&&ResultSet.TYPE_SCROLL_INSENSITIVE,//该常量指示可滚动但通常不受其他的更改影响的&ResultSet&对象的类型。&&&&&&&&&&&&&&&&&&&&&&ResultSet.CONCUR_READ_ONLY);//该常量指示不可以更新的&ResultSet&对象的并发模式&&&&&&&&&&&&&&&&&&&&&&&&&&&&rs&=&pstmt.executeQuery();&&&&&&&&&&&&&&&&Log.debug(this,&"getDPCurrentPage(int&currentPageNo,&int&pageSize)",&sql.toString());&&&&&&&&&&&&&&&&if&(rs.absolute(start))&{//把rs移到当前页的开始行&&&&&&&&&&&&&&&&&&listDP&=&new&ArrayList();&&&&&&&&&&&&&&&&&&while&(rs.getRow()&&=&total)&{&&&&&&&&&&&&&&&&&&&&&&DubietyPosition&dp&=&new&DubietyPosition();&&&&&&&&&&&&&&&&&&&&&&dp.setPosId(rs.getInt("posid"));&&&&&&&&&&&&&&&&&&&&&&dp.setComname(rs.getString("comname"));&&&&&&&&&&&&&&&&&&&&&&dp.setPosname(rs.getString("posname"));&&&&&&&&&&&&&&&&&&&&&&dp.setAddress(rs.getString("address_pc"));&&&&&&&&&&&&&&&&&&&&&&dp.setReqWorkYear(rs.getInt("reqworkyear"));&&&&&&&&&&&&&&&&&&&&&&dp.setReqDegreeName(rs.getString("reqDegreeName"));&&&&&&&&&&&&&&&&&&&&&&//&把可疑职位添加到可疑职位列表中&&&&&&&&&&&&&&&&&&&&&&listDP.add(dp);&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&/*&&&&&&&&&&&&&&&&&&&&&&*&rs.next()的作用是使rs.getRow()每次都加1,还有当页面不足要求的记录时可以跳出循环,防止null异常&&&&&&&&&&&&&&&&&&&&&&*/&&&&&&&&&&&&&&&&&&&&&&if&(!rs.next())&{&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&}&&&&&&&&&&&&&&&&&&}&&&&&&&&&&&&&&}&&&&&&&&&&}&catch&(Exception&e)&{&&&&&&&&&&&&&&Log.error(this,&"getDPCurrentPage(int&currentPageNo,&int&pageSize)",&e.getMessage());&&&&&&&&&&}&finally&{&&&&&&&&&&&&&&DBUtil.clean(this,&rs);&&&&&&&&&&&&&&DBUtil.clean(this,&pstmt);&&&&&&&&&&&&&&DBUtil.clean(this,&conn);&&&&&&&&&&}&&&&&&&&&&return&listDP;&&&&&&}&&&&&&&&}&&/**
* DubietyPosition.java
* 这是一个装载可疑职位的类
* 用于可疑职位信息筛选
Java代码 &package&com.jobcn.weihu.&&&&public&class&DubietyPosition&{&&&&&&&&//&职位id&&&&&&private&int&posId;&&&&&&&&//&招聘职位名&&&&&&private&String&&&&&&&&&//&公司名&&&&&&private&String&&&&&&&&&//&地址&&&&&&private&String&&&&&&&&&//&要求学历&&&&&&private&String&reqDegreeN&&&&&&&&//&工作经验&&&&&&private&int&reqWorkY&&&&&&&&public&int&getPosId()&{&&&&&&&&&&return&posId;&&&&&&}&&&&&&&&public&void&setPosId(int&posId)&{&&&&&&&&&&this.posId&=&posId;&&&&&&}&&&&&&&&public&String&getPosname()&{&&&&&&&&&&return&&&&&&&}&&&&&&&&public&void&setPosname(String&posname)&{&&&&&&&&&&this.posname&=&&&&&&&}&&&&&&&&public&String&getComname()&{&&&&&&&&&&return&&&&&&&}&&&&&&&&public&void&setComname(String&comname)&{&&&&&&&&&&this.comname&=&&&&&&&}&&&&&&&&public&String&getAddress()&{&&&&&&&&&&return&&&&&&&}&&&&&&&&public&void&setAddress(String&address)&{&&&&&&&&&&this.address&=&&&&&&&}&&&&&&&&public&String&getReqDegreeName()&{&&&&&&&&&&return&reqDegreeN&&&&&&}&&&&&&&&public&void&setReqDegreeName(String&reqDegreeName)&{&&&&&&&&&&this.reqDegreeName&=&reqDegreeN&&&&&&}&&&&&&&&public&int&getReqWorkYear()&{&&&&&&&&&&return&reqWorkY&&&&&&}&&&&&&&&public&void&setReqWorkYear(int&reqWorkYear)&{&&&&&&&&&&this.reqWorkYear&=&reqWorkY&&&&&&}&&} &
推一荐:&&|&&
喜欢该文的人也喜欢

我要回帖

更多关于 java下拉列表框 的文章

 

随机推荐