我的数据库中有一些值,如果尚未输入,则可以为null.
但是当我在我的html中使用Thymeleaf时,它在解析空值时会出错.
有办法处理这个吗?
我有一个双号,是"547.123456"
我只是想把这个双重用作"547.1",就像"."之后只有1个数字一样.
我怎样才能做到这一点?
我有一个50 Object秒的阵列.
我希望List每次应用程序启动时随机获取4个对象.
而不是把它们放在一个Map.
如何从数组中随机取出4个对象?
这是我的代码示例:
ArrayList<Deal> dealsTodayArray = dealsToday.getDeals();
Map<String, Object> map = new HashMap<String, Object>();
map.put("dealsTodayFirst", dealsTodayFirst);
map.put("dealsTodaySecond", dealsTodaySecond);
map.put("dealsTodayThird", dealsTodayThird);
map.put("dealsTodayForth", dealsTodayForth);
Run Code Online (Sandbox Code Playgroud) 我用Apache POI创建了Excel文件.
在我的数据库中,我有一个400人的列表.我想将他们的姓名和姓氏写入该Excel文件.
这是我的代码示例:
try {
FileOutputStream fileOut = new FileOutputStream("C:/testExcelForJava/test.xls");
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet worksheet = workbook.createSheet("POI Worksheet");
// index from 0,0... cell A1 is cell(0,0)
HSSFRow row1 = worksheet.createRow((short) 0);
HSSFCell cellA1 = row1.createCell((short) 0);
cellA1.setCellValue("Ad");
HSSFCellStyle cellStyle = workbook.createCellStyle();
cellStyle.setFillForegroundColor(HSSFColor.GOLD.index);
cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
cellA1.setCellStyle(cellStyle);
HSSFCell cellB1 = row1.createCell((short) 1);
cellB1.setCellValue("Soyad");
cellStyle = workbook.createCellStyle();
cellStyle.setFillForegroundColor(HSSFColor.GOLD.index);
cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
cellB1.setCellStyle(cellStyle);
List<Driver> driverList = Dao.driverDao.queryForAll();
for(Driver driver :driverList){
String name = driver.getName();
String surname = driver.getSurname();
String birthDay = driver.getBirthDay();
cellA1.setCellValue(name);
cellB1.setCellValue(surname); …Run Code Online (Sandbox Code Playgroud)