冲不动 2018-01-24 16:17 采纳率: 33.3%
浏览 1972
已采纳

freemarker生成模板在windows下正常运行而在linux下报错数组越界

我需要使用freemarker生成html文件,在windows系统下能够正常运行,但是在linux系统下报错数组越界。

下面是代码:

    public boolean generateHotArticleFreeMarker(PageData pd) throws Exception {
        Configuration configuration = freeMarkerConfigurer.getConfiguration();
        Template template = configuration.getTemplate("hotarticle.ftl");
        PageData map = new PageData();

        Result result = hotArticleService.getHotArticleList(pd);
        map.put("totalPage", result.getTotalPage());
        map.put("currentPage", result.getCurrentPage());
        map.put("rows", result.getRows().size() > 0 ? result.getRows() : "");

        List<TbCategory> categoryList = categoryService.getCategoryList();
        map.put("categoryList", categoryList);

        map.put("resultPd", pd);
        FileWriter out = new FileWriter(new File(FREEMARKER_PATH + pd.getString("id") + ".html"));
        template.process(map, out);

        out.close();
        return true;
    }

在执行到template.process(map, out);这一行时候报错:

 java.lang.ArrayIndexOutOfBoundsException: 415315061
    at java.util.HashMap.putForCreate(HashMap.java:541)
    at java.util.HashMap.putAllForCreate(HashMap.java:555)
    at java.util.HashMap.clone(HashMap.java:796)
    at freemarker.template.SimpleHash.copyMap(SimpleHash.java:153)
    at freemarker.template.SimpleHash.<init>(SimpleHash.java:133)
    at freemarker.template.DefaultObjectWrapper.wrap(DefaultObjectWrapper.java:230)
    at freemarker.template.Template.createProcessingEnvironment(Template.java:475)
    at freemarker.template.Template.process(Template.java:382)
    at com.goodlymoon.portal.service.freemarker.HtmlFreeMarker.generateHotArticleFreeMarker(HtmlFreeMarker.java:94)
    at com.goodlymoon.portal.service.impl.HotArticleServiceImpl.saveHotArticle(HotArticleServiceImpl.java:98)
    at com.goodlymoon.portal.service.impl.HotArticleServiceImpl.getWinXinHotArticle(HotArticleServiceImpl.java:155)
    at com.goodlymoon.portal.service.impl.HotArticleServiceImpl$$FastClassBySpringCGLIB$$19625a23.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655)
    at com.goodlymoon.portal.service.impl.HotArticleServiceImpl$$EnhancerBySpringCGLIB$$7c74333.getWinXinHotArticle(<generated>)
    at com.goodlymoon.portal.service.timer.QuartzTask$HotArticleTask.run(QuartzTask.java:97)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)

有没有大神帮忙看看有什么好的解决办法吗?

我觉得路径是没有问题的,因为在指定的文件夹下生成了文件,只是没有写入内容,附图片
图片说明

  • 写回答

10条回答 默认 最新

  • fsp357838 2018-01-24 16:29
    关注

    你确定在两个系统上是对同样的文件使用freemarker?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(9条)

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘