我需要使用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)
有没有大神帮忙看看有什么好的解决办法吗?
我觉得路径是没有问题的,因为在指定的文件夹下生成了文件,只是没有写入内容,附图片