Unable to resolve resource bundle for locale "en_US".

本文解决了FlexViewer项目在Tomcat部署时遇到的资源包找不到问题。通过在AdditionalCompilerarguments中添加特定参数来指定资源的位置。

       今天把一个FlexViewer的工程由文件发布转为发布到Tomcat上面,一切准备就绪,但是编译的时候提示“Unable to resolve resource bundle "ControllerStrings" for locale "en_US".  网上一搜索很多方法,可是就是解决不了,什么加入库啊,什么修改编译参数啦,统统不管用。还是我师弟牛屄啊,一个提醒让我查到了解决方案,如下:

 

       右键项目属性,在Flex Compiler里面,Additional Compiler arguments这个文本框中添加:

       

                                       

       记住哦,这个-source-path里面的路径是你项目工程中nls资源的路径。重新编译,一切OK~ Good Luck!

## 报错的代码 Path excelPath = Paths.get(importConfig.getZipTempDir(), fileName); ## 代码详细方法 File tempDir = new File(importConfig.getZipTempDir()); if (!tempDir.exists()) { tempDir.mkdirs(); } List<Path> excelFiles = new ArrayList<>(); for (String entityId : clbxId) { IcpmExpenseReimbursement fyEntity = (IcpmExpenseReimbursement) this.loadEntity(IcpmExpenseReimbursement.class, entityId); if (StringUtil.checkNull(fyEntity)) { continue; } String fileName = dateMonth + "月_" + fyEntity.getUserName() + "_" + IcpmBusiEnum.EXPORT_ALL.getEncodedVal(); String normalizedFileName = Normalizer.normalize(fileName, Normalizer.Form.NFC); Path excelPath = Paths.get(importConfig.getZipTempDir(), normalizedFileName); try (InputStream ins = this.getClass().getResourceAsStream(IcpmBusiEnum.EXPORT_ALL.getCode()); Workbook workbook = new XSSFWorkbook(ins); FileOutputStream fileOut = new FileOutputStream(excelPath.toFile())) { // 填充模板 this.fillTemplateWithDataZip(workbook, fyEntity, dateMonth); workbook.write(fileOut); excelFiles.add(excelPath); } } if (excelFiles.isEmpty()) { throw new ResultException(ApiStatusCode.VAILD_ERROR.getCode(), "当前月份导出失败!请重新选择!"); } // 设置响应头 response.reset(); response.setContentType("application/zip"); response.setHeader("Content-Disposition", "attachment; filename=\"" + URLEncoder.encode(dateMonth + "月费用报销数据.zip", "UTF-8") + "\""); response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); response.setHeader("Pragma", "no-cache"); response.setDateHeader("Expires", 0); // 写入ZIP包 try (ZipOutputStream zipOut = new ZipOutputStream(new BufferedOutputStream(response.getOutputStream()))) { for (Path excelPath : excelFiles) { try (FileInputStream fileIn = new FileInputStream(excelPath.toFile())) { ZipEntry zipEntry = new ZipEntry(excelPath.getFileName().toString()); zipOut.putNextEntry(zipEntry); byte[] buffer = new byte[8192]; int bytesRead; while ((bytesRead = fileIn.read(buffer)) != -1) { zipOut.write(buffer, 0, bytesRead); } zipOut.closeEntry(); } } zipOut.flush(); } for (Path excelPath : excelFiles) { Files.deleteIfExists(excelPath); } ## 错误日志 ava.nio.file.InvalidPathException: Malformed input or input contains unmappable characters: /tmp/icpm-zip/2025-07?_?????_???????????.xlsx at sun.nio.fs.UnixPath.encode(UnixPath.java:147) ~[na:1.8.0_231] at sun.nio.fs.UnixPath.<init>(UnixPath.java:71) ~[na:1.8.0_231] at sun.nio.fs.UnixFileSystem.getPath(UnixFileSystem.java:281) ~[na:1.8.0_231] at java.nio.file.Paths.get(Paths.java:84) ~[na:1.8.0_231] ## 任务场景 上面这行代码在windows下不报错,是正常的压缩包,但在Linux下有问题 打印出来的文件全称为: 2025-07月_系统管理员_差旅报销单及费用报销单.xlsx cat /etc/redhat-release CentOS Linux release 7.9.2009 (Core) ## 任务 解决此bug ## 代码解释 importConfig.getZipTempDir() = /tmp/icpm-zip/ String fileName = dateMonth + "月_" + fyEntity.getUserName() + "_" + IcpmBusiEnum.EXPORT_ALL.getEncodedVal(); EXPORT_ALL("/export/ClbxAndFybx.xlsx","费用报销单.xlsx"), ## 自己尝试解决的方法 都没能解决这个问题 我试了java -Dfile.encoding=UTF-8、Path excelPath = new File(importConfig.getZipTempDir(), fileName).toPath(); locale LANG=en_US.UTF-8 LC_CTYPE="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL=en_US.UTF-8
最新发布
07-16
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值