精华内容
下载资源
问答
  • uReport
    2021-12-14 09:43:14

    UReport2导出word格式文件提示“无法访问此网站”

    查看服务器报错日志:

    2021-12-13 17:50:02,286[DEBUG][io.lettuce.core.RedisChannelHandler:76]-dispatching command AsyncCommand [type=HGETALL, output=MapOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
    2021-12-13 17:50:02,289[ERROR][org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[UReportServlet]:182]-Servlet.service() for servlet [UReportServlet] in context with path [] threw exception [Servlet execution threw an exception] with root cause
    java.lang.NoSuchMethodError: org.apache.poi.xwpf.usermodel.XWPFParagraph.setSpacingBetween(D)V
    	at com.bstek.ureport.export.word.high.WordProducer.buildTableCellStyle(WordProducer.java:464) ~[ureport2-core.jar:?]
    	at com.bstek.ureport.export.word.high.WordProducer.produce(WordProducer.java:150) ~[ureport2-core.jar:?]
    	at com.bstek.ureport.export.ExportManagerImpl.exportWord(ExportManagerImpl.java:110) ~[ureport2-core.jar:?]
    	at com.bstek.ureport.console.word.ExportWordServletAction.buildWord(ExportWordServletAction.java:81) ~[ureport2-console.jar:?]
    	at com.bstek.ureport.console.word.ExportWordServletAction.execute(ExportWordServletAction.java:55) ~[ureport2-console.jar:?]
    	at com.bstek.ureport.console.UReportServlet.service(UReportServlet.java:81) ~[ureport2-console.jar:?]
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) ~[javax.servlet-api.jar:3.1.0]
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core.jar:8.5.34]
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core.jar:8.5.34]
    	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-embed-websocket.jar:8.5.34]
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core.jar:8.5.34]
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core.jar:8.5.34]
    	at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:90) ~[spring-boot-actuator.jar:2.0.5.RELEASE]
    	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web.jar:5.0.9.RELEASE]
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core.jar:8.5.34]
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core.jar:8.5.34]
    	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ~[spring-web.jar:5.0.9.RELEASE]
    	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web.jar:5.0.9.RELEASE]
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core.jar:8.5.34]
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core.jar:8.5.34]
    	at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109) ~[spring-web.jar:5.0.9.RELEASE]
    	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web.jar:5.0.9.RELEASE]
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core.jar:8.5.34]
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core.jar:8.5.34]
    	at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) ~[spring-web.jar:5.0.9.RELEASE]
    	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web.jar:5.0.9.RELEASE]
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core.jar:8.5.34]
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core.jar:8.5.34]
    	at org.springframework.session.web.http.SessionRepositoryFilter.doFilterInternal(SessionRepositoryFilter.java:147) ~[spring-session-core.jar:2.0.6.RELEASE]
    	at org.springframework.session.web.http.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:81) ~[spring-session-core.jar:2.0.6.RELEASE]
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core.jar:8.5.34]
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core.jar:8.5.34]
    	at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:155) ~[spring-boot-actuator.jar:2.0.5.RELEASE]
    	at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:123) ~[spring-boot-actuator.jar:2.0.5.RELEASE]
    	at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:108) ~[spring-boot-actuator.jar:2.0.5.RELEASE]
    	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web.jar:5.0.9.RELEASE]
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core.jar:8.5.34]
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core.jar:8.5.34]
    	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) ~[spring-web.jar:5.0.9.RELEASE]
    	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web.jar:5.0.9.RELEASE]
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core.jar:8.5.34]
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core.jar:8.5.34]
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) [tomcat-embed-core.jar:8.5.34]
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core.jar:8.5.34]
    	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) [tomcat-embed-core.jar:8.5.34]
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [tomcat-embed-core.jar:8.5.34]
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) [tomcat-embed-core.jar:8.5.34]
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [tomcat-embed-core.jar:8.5.34]
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) [tomcat-embed-core.jar:8.5.34]
    	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800) [tomcat-embed-core.jar:8.5.34]
    	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core.jar:8.5.34]
    	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806) [tomcat-embed-core.jar:8.5.34]
    	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498) [tomcat-embed-core.jar:8.5.34]
    	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core.jar:8.5.34]
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_212]
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_212]
    	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core.jar:8.5.34]
    	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_212]
    

    日志提示没有找到“setSpacingBetween”方法,接下来就是去翻底层代码,发现如下代码用到了

    org.apache.poi.xwpf.usermodel包下XWPFParagraph下的“setSpacingBetween”方法,该代码块首先判断了“行高”是否大于0,true则调用“setSpacingBetween”方法:

    if (style.getLineHeight() > 0.0F) {
        para.setSpacingBetween((double)style.getLineHeight());
    }

    由于才疏学浅,“setSpacingBetween方法为什么没找到还有待验证,目前怀疑可能是jar包冲突造成的。

    自己的解决办法是打开报表设计器选中对应行,设置行高为0暂时避免报错(如需设置行高就手动拖拽拉高即可)

    更多相关内容
  • 概述UReport2是基于Spring架构的高性能纯Java报告引擎,其中可以通过在单元格上进行迭代来准备复杂的中文样式的语句和报告。 UReport2提供了全新的基于Web的报表设计器,该设计器可在主流浏览器中运行,包括Chrome,...
  • springboot-ureport 此项目用于大家学习,如有错误,请指出!共同进步 简介: 1、项目使用Maven管理 2、项目使用 spring boot + mybatis 3、项目集成 ureport 报表框架 4、提供ureport 数据源配置 5、提供Mysql、FTP...
  • UReport Demo 此项目是 产品和 Spring Boot 整合后的一个实例 Spring Boot 集成 报表可保存至数据库,JpaReportProvider 一个简单的 Web UI 使用 下载源码 git clone https://github.com/yingw/ureport-demo.git --...
  • ureport报表文件
  • Springboot_ureport

    2021-02-22 07:20:30
    springboot-ureport 此项目用于大家学习,如有错误,请指出!共同进步 简介: 1,项目使用Maven管理 2,项目使用spring boot + mybatis 3,项目集成ureport报表框架 4,提供ureport数据源配置 5,提供Mysql,FTP...
  • ureport2教学视频

    2020-03-31 19:59:02
    珍贵ureport2视频资料。包括入门和升级以及实际项目中的配置问题。从头到尾解决所有的报表导出问题。方便快捷的适用。
  • ureport2.rar

    2020-05-13 14:36:37
    下下来了之后,配置自己的路径和数据库,这是一个单独的报表服务,系统通过后台访问报表服务,系统的访问java和页面和页面的js也已经写好,参照自己的系统修改
  • 效果见图 Ureprot右侧求和,经典操作,这个是这个贴子的答案。 https://bbs.csdn.net/topics/399129750 https://img-bbs.csdn.net/upload/202103/27/1616848520_741648.png
  • ureport2自己的jar包

    2020-03-24 20:26:32
    UReport2自己的Jar包有三个,分别是ureport2-core、ureport2-font及ureport2-console 这个是2.2.9版本的
  • UReport 项目中的使用方法,项目中的配置,报表的制作案例,使用手册
  • springboot集成Ureport2 与业务结合//报表名称要以其ReportProvider中要求的前缀开始, 比如http://localhost:8080/ureport2-demo/ureport/preview?_u=file:test.ureport.xml等。
  • ureport-项目 基于最新的 Rapidsms 0.13.0 和 github.com/nyaruka 的 httprouter 的新 ureport 建立 git clone https://github.com/unicefburundi/ureport-project.git ureport_project cd ureport_project pip ...
  • UReport2报表引擎-其他

    2021-06-12 08:58:34
    UReport2是一款高性能的架构在Spring之上纯Java报表引擎,通过迭代单元格可以实现任意复杂的中国式报表。 在UReport2中,提供了全新的基于网页的报表设计器,可以在Chrome、Firefox、Edge等各种主流浏览器运行(IE...
  • 此包中包含UReport2的使用手册(docx/typora)、源码、自己开发的微服务单体应用demo案例,修改了源码图表色板bug。
  • Spring Boot 整合 Ureport2, Mybatis Puls,表格demo样例(简单列表,图表,表单简单使用)。基础功能以实现,可在基础上进行业务开发(以具体情况为准)
  • ureport-master.zip

    2020-08-09 18:07:01
    UReport2是一款高性能的架构在Spring之上纯Java报表引擎,通过迭代单元格可以实现任意复杂的中国式报表。 在UReport2中,提供了全新的基于网页的报表设计器,可以在Chrome、Firefox、Edge等各种主流浏览器运行(IE...
  • Ureport 2 第三方资源库

    2017-08-28 10:19:37
    ureport2 想要的第三方jar包文件。
  • springCloud集成ureport,并通过网关访问的源码修改, 这里写好了相关源码修改,modifybyStrike的部分就是修改的部分
  • UReport2是一款高性能的Java报表引擎,提供完善的基于网页的报表设计器,可快速做出各种复杂的中式报表
  • youseries-ureport-master.zip

    2020-03-27 12:18:30
    ureport 又一款Java语言报表制作工具 欢迎下载使用
  • ureport-p.pdf

    2019-06-05 18:20:19
    报表工具ureport最详细的文档,使用于ureport各个版本
  • 离线安装包,亲测可用
  • ureport_source_code 来源原始码,eclipse项目,删除setting等文件,导入idea,修改buildImage方法
  • 报告匿名报告客户端在 srcHacks 2018 上创建的初始版本,但在接下来的几个月中发生了重大变化。 这个软件的想法是它允许学生匿名向老师报告事情,例如作弊或欺凌。 这涉及我们的服务器向老师发送一封电子邮件,其中...
  • UReport2 与业务结合

    千次阅读 2021-06-16 03:46:13
    报表相关URL在配置好一个包含UReport2的项目后,就可以运行我们的项目,打开UReport2的基于网页的报表设计器,它的地址如下:UReport2报表设计器URLhttp://host[:port][/context-path]/ureport/designer如果我们是在...

    本小节中我们将介绍如何在业务页面中展示报表、导出报表文件、引用报表内容等操作。

    报表相关URL

    在配置好一个包含UReport2的项目后,就可以运行我们的项目,打开UReport2的基于网页的报表设计器,它的地址如下:UReport2报表设计器URL

    http://host[:port][/context-path]/ureport/designer

    如果我们是在本地启动项目,并且服务器端口号为8080,context-path为ureport2-demo,那么我们的报表设计器的URL就是:http://localhost:8080/ureport2-demo/ureport/designer。

    在报表设计器中,设计好报表后,点击左上角的

    6f9cc799a0bfad55147ac1c5a23e827d.png图标就可以在线预览报表(预览报表有两种方式,一种是不分页预览报表;一种是分页预览报表,如果报表数据量较大,我们推荐预览时采用分页方式,这样可以减轻浏览器渲染压力);预览报表的URL如下:UReport2预览报表URL

    http://host[:port][/context-path]/ureport/preview?_u=报表名称

    在上面的URL中有个名为“_u”的参数,它是用来指定当前要预览的报表模版名称,如果是对正在设计器中的报表进行预览,那么它的值就是“p”,这是一个约定的值,表示要预览的是正在设计器中的报表,所以可以看到我们演示时预览的URL都是这样:http://localhost:8080/ureport2-demo/ureport/preview?_u=p 。预览正在设计中的报表注意事项

    在预览正在设计器中设计的报表时(也就是_u=p),UReport2会在点击设计器工具栏

    6f9cc799a0bfad55147ac1c5a23e827d.png图标时,将设计中的报表模版信息提交到服务器,存放于当前用户的session中(用户会话中),所以一旦用户session失效,如果我们再次直接预览_u=p类型报表时,会看到“com.bstek.ureport.console.exception.ReportDesignException: Report data has expired,can not do preview.”这样的错误提示,表示存放于session中的正在设计器中设计的报表模版已经失效,不能预览。

    当然,如果_u的值是一个具体的报表名称,则不存在这种问题,只有正在设计器中设计的报表模版在预览中采用了这种机制,这点需要注意。

    如果预览的不是正在设计器中设计的模版,那么只需要给出具体的报表名称即可,需要注意的是,这里的报表名称要以其ReportProvider中要求的前缀开始,比如http://localhost:8080/ureport2-demo/ureport/preview?_u=file:test.ureport.xml等。

    报表预览后,通过预览页面上方工具栏中一排按钮,可以实现报表的PDF打印、导出Word、Excel、PDF等,对应的相关URL如下:URL说明http://host[:port][/context-path]/ureport/pdf/show?_u=报表名称这个URL将向浏览器写入一个PDF文件流,在Chrome、Firefox、Edge这些

    浏览器中将会直接在线显示PDF文件内容,这样可以实现在线浏览PDF并打印输出。

    http://host[:port][/context-path]/ureport/word?_u=报表名称导出对应报表的Word文件

    http://host[:port][/context-path]/ureport/excel?_u=报表名称不分页导出对应报表的Excel文件

    http://host[:port][/context-path]/ureport/excel/paging?_u=报表名称分页导出对应报表的Excel文件

    http://host[:port][/context-path]/ureport/excel/sheet?_u=报表名称分页分Sheet导出对应报表的Excel文件

    http://host[:port][/context-path]/ureport/pdf?_u=报表名称导出对应报表的PDF文件关于报表参数

    上面的这些URL在使用时,如果需要向报表传入参数,可以将这些参数直接放在URL后面使用,如:http://localhost:8080/ureport2-demo/ureport/word?_u=file:test.ureport.xml&deptId=D11&age=50,将报表file:test.ureport.xml导出成word时,传入两个参数,分别是:deptId=D11以及age=50

    上述的这些URL后面除了可以用_u参数来指定要预览的报表名称外,还可以通过_i参数来指定当前要预览报表页码,也就是说如果上述这些URL后面没有_i参数,将会显示整个报表,如果有则显示_i参数指定页码对应的报表,比如URL后面跟_i=2,表示预览报表分页后第2页内容。

    在http://host[:port][/context-path]/ureport/preview对应的HTML报表预览页面中,默认页面上部工具栏会显示一排按钮,用于实现打印和导出其它格式报表,如下图所示:

    c05d856bfdac02bbca3e8ff7643f4cff.png

    在上面的工具栏中,一共有9个按钮,分别用于实现打印及导出其它格式报表, 在实际使用中,如果希望这个工具栏只出现其中某些个工具的话,我们可以参数在URL后面添加_t参数来实现,_t参数如果不指定,那么会显示所有的按钮,否则只显示_t参数指定的按钮。上面这些按钮的显示分别对应参数值:1、2、3、4、5、6、7、8、9,多个参数间用“,”分隔,下面是一些示例:示例说明_t=1,3显示第一个和第三个按钮

    _t=1,2,5显示第一个,第二个和第五个按钮

    _t=1,2,3,4,5显示第一个,第二个,第三个,第四个和第五个按钮

    如果我们不希望显示HTML预览页面的工具栏,那么设置_t=0即可。关于在线打印

    在UReport2的报表预览页面中,可以看到UReport2提供了三种在线打印方式,分别是直接HTML打印、直接PDF打印以及PDF在线预览打印。这其中直接HTML打印是利用浏览器的HTML打印功能实现,能用于普通的A4纸类型报表页面的打印,同时它不能打印出报表中定义的页眉页脚,如果有定义的话。对于直接PDF打印以及PDF在线预览打印是服务端向浏览器中写入PDF流,利用Chrome、Firefox、Edge这些浏览器可以在线显示PDF功能实现的打印,这种是直接打印的PDF,所以可以应付各种复杂报表纸张类型的打印输出。Firefox在预览PDF时存在的问题

    在预览PDF时,Firefox不允许当前frame外通过javascript调用其打印功能(目前来看可能是Firefox的Bug),所以我们需要手工点击其frame内部自带的打印按钮实现打印。

    在业务页面中,如果需要预览打印或导出报表,那么就可以采用上述URL实现需要的功能。

    在代码中使用报表

    在UReport2当中,我们可以使用ExportManager实现在业务代码中导出各种类型的报表,ExportManager接口源码如下:package com.bstek.ureport.export;

    import java.util.Map;

    import com.bstek.ureport.export.html.HtmlReport;

    /**

    * @author Jacky.gao

    * @since 2016年12月4日

    */

    public interface ExportManager {

    public static final String BEAN_ID="ureport.exportManager";

    /**

    * 导出Html报表

    * @param file 报表模版文件名

    * @param contextPath 当前项目的context path

    * @param parameters 参数

    * @return 返回一个HtmlReport对象,里面有报表产生的HTML及相关CSS

    */

    HtmlReport exportHtml(String file,String contextPath,Map parameters);

    /**

    * 导出指定页码的Html报表

    * @param file 报表模版文件名

    * @param contextPath 当前项目的context path

    * @param parameters 参数

    * @param pageIndex 页码

    * @return 返回一个HtmlReport对象,里面有报表产生的HTML及相关CSS

    */

    HtmlReport exportHtml(String file,String contextPath,Map parameters,int pageIndex);

    /**

    * 导出PDF报表

    * @param config 包含报表模版文件名、参数等信息的配置对象

    */

    void exportPdf(ExportConfigure config);

    /**

    * 不分页导出Excel

    * @param config 包含报表模版文件名、参数等信息的配置对象

    */

    void exportExcel(ExportConfigure config);

    /**

    * 分页导出Excel

    * @param config 包含报表模版文件名、参数等信息的配置对象

    */

    void exportExcelWithPaging(ExportConfigure config);

    /**

    * 分页分Sheet导出Excel

    * @param config 包含报表模版文件名、参数等信息的配置对象

    */

    void exportExcelWithPagingSheet(ExportConfigure config);

    /**

    * 导出Word

    * @param config 包含报表模版文件名、参数等信息的配置对象

    */

    void exportWord(ExportConfigure config);

    }

    因为ExportManager接口实现是配置在Spring当中,所以要使用ExportManager接口,我们需要首先通过Spring的ApplicationContext取到ExportManager实例对象,我们可以通过ExportManager.BEAN_ID来取到对应的Bean实例。我们来看下如何采用ExportManager导出HTML报表,并将报表内容嵌入到一个JSP中。

    首先我们需要采用报表设计器设计好一个报表模版文件,将其保存,比如报表模版保存后的文件名为demo.ureport.xml,然后在项目中创建一个JSP(这里之所以选择JSP,是因为它最为简单,可以保证所有的J2EE开发者都能看懂,实际使用时可能是MVC框架、Ajax等,但如果了解了在JSP中用法,其它的就简单了),在JSP中输入相应代码,导出Html报表,并将其写入到JSP中,完整的JSP源码如下:

    HTML报表测试

    导出PDF格式报表

    ExportManager exportManager=(ExportManager)Utils.getApplicationContext().getBean(ExportManager.BEAN_ID);

    Map parameters=new HashMap();

    HtmlReport htmlReport = exportManager.exportHtml("file:demo.ureport.xml",request.getContextPath(),parameters);

    //输出Css样式

    out.println("

    out.println(htmlReport.getStyle());

    out.println("");

    //输出报表内容

    out.println(htmlReport.getContent());

    %>

    启动项目,浏览这个JSP,就可以看到生成的HTML报表内容,如下图所示:

    95fd7377b63b73657cfafae12b7c85c4.png

    可以看到,在运行后的JSP中,可以点击上方的链接导出PDF格式报表,下方的表格则是这个报表的HTML格式展现,实际使用时还可以在这个页面里加入一些其它与业务相关元素,具体做法这里就不再赘述。

    展开全文
  • springboot2.x集成ureport2.2.9搭建报表引擎1、创建springboot项目,修改pom.xml添加相关依赖2、增加src/main/resources/context.properties3、修改src/main/resources/application.yml4、增加...

    1、创建springboot项目,修改pom.xml添加相关依赖

    pom.xml内容如下:

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    	<modelVersion>4.0.0</modelVersion>
    	<parent>
    		<groupId>org.springframework.boot</groupId>
    		<artifactId>spring-boot-starter-parent</artifactId>
    		<version>2.6.3</version>
    		<relativePath/>
    	</parent>
    	<groupId>com.wongoing</groupId>
    	<artifactId>wgms-report-server</artifactId>
    	<version>0.0.1-SNAPSHOT</version>
    	<name>wgms-report-server</name>
    	<description>Demo project for Spring Boot</description>
    	<properties>
    		<java.version>1.8</java.version>
    	</properties>
    	<dependencies>
    		<dependency>
    			<groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <scope>provided</scope>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework.boot</groupId>
    			<artifactId>spring-boot-starter-web</artifactId>
    		</dependency>
    		<!-- 增加常用数据库驱动依赖 -->
    		<dependency>
    			<groupId>com.microsoft.sqlserver</groupId>
    			<artifactId>mssql-jdbc</artifactId>
    			<scope>runtime</scope>
    		</dependency>
    		<dependency>
    			<groupId>com.oracle.database.jdbc</groupId>
    			<artifactId>ojdbc8</artifactId>
    			<scope>runtime</scope>
    		</dependency>
    		<dependency>
    			<groupId>mysql</groupId>
    			<artifactId>mysql-connector-java</artifactId>
    			<scope>runtime</scope>
    		</dependency>
    		<dependency>
    			<groupId>org.postgresql</groupId>
    			<artifactId>postgresql</artifactId>
    			<scope>runtime</scope>
    		</dependency>
    		<!--连接池-->
    		<dependency>
    		   <groupId>com.alibaba</groupId>
    		   <artifactId>druid-spring-boot-starter</artifactId>
    		   <version>1.2.8</version>
    		</dependency>
    		<!-- ureport -->
    		<dependency>
    		    <groupId>com.bstek.ureport</groupId>
    		    <artifactId>ureport2-console</artifactId>
    		    <version>2.2.9</version>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework.boot</groupId>
    			<artifactId>spring-boot-starter-test</artifactId>
    			<scope>test</scope>
    		</dependency>
    	</dependencies>
    
    	<build>
    		<plugins>
    			<plugin>
    				<groupId>org.springframework.boot</groupId>
    				<artifactId>spring-boot-maven-plugin</artifactId>
    			</plugin>
    		</plugins>
    	</build>
    
    </project>
    

    2、增加src/main/resources/context.properties

    内容如下:
    ureport.fileStoreDir=F:/ureportfiles

    3、修改src/main/resources/application.yml

    内容如下:

    server:
      port: 9999
    ####################  项目级数据源配置  ###################
    spring:
      datasource:
        name: archimedes
        #generate-unique-name为false时,name的值才会生效
        generate-unique-name: false
        url: jdbc:mysql://localhost:3306/archimedes?useUnicode=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8
        username: root
        password: root@123
        driver-class-name: com.mysql.cj.jdbc.Driver
    

    4、增加com.wongoing.config.ReportConfig.java配置类

    内容如下

    package com.wongoing.config;
    
    import java.io.IOException;
    
    import javax.servlet.Servlet;
    
    import org.springframework.boot.web.servlet.ServletRegistrationBean;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.context.annotation.ImportResource;
    import org.springframework.core.io.ClassPathResource;
    
    import com.bstek.ureport.UReportPropertyPlaceholderConfigurer;
    import com.bstek.ureport.console.UReportServlet;
    
    import lombok.extern.slf4j.Slf4j;
    /**
     * 功能说明:springboot集成ureport的配置类
     * 修改说明:
     * @author zheng
     * @date 2022-1-21 9:44:57
     * @version 0.1
     */
    //导入ureport-console-context.xml文件
    @ImportResource("classpath:ureport-console-context.xml")
    @Configuration
    @Slf4j
    public class ReportConfig {
    
    	/**
    	 * 功能说明:注册report的servlet
    	 * 修改说明:
    	 * @author zheng
    	 * @date 2022-1-21 9:43:49
    	 * @return
    	 */
    	@Bean
    	public ServletRegistrationBean<Servlet> ureport2Servlet() {
    		return new ServletRegistrationBean<>(new UReportServlet(), "/ureport/*");
    	}
    	
    	/**
    	 * 功能说明:加载context.properties配置文件
    	 * 修改说明:
    	 * @author zheng
    	 * @date 2022-1-21 9:44:37
    	 * @return
    	 * @throws IOException 
    	 */
    	@Bean
    	public UReportPropertyPlaceholderConfigurer UReportPropertyPlaceholderConfigurer() throws IOException {
    		UReportPropertyPlaceholderConfigurer propertyConfigurer = new UReportPropertyPlaceholderConfigurer();
    		propertyConfigurer.setIgnoreUnresolvablePlaceholders(true);
    		org.springframework.core.io.DefaultResourceLoader df = new org.springframework.core.io.DefaultResourceLoader();
    		String userDir = System.getProperty("user.dir");			//获取当前jar运行的路径
    		log.info(userDir);
    		
    		//如果jar所在目录下有config/context.properties,则加载
    		String configFilePath = String.format("file:///%s/%s", userDir, "config/context.properties");
    		log.info(configFilePath);
    		org.springframework.core.io.Resource configResource =  df.getResource(configFilePath);
    		if (configResource.exists()) {
    			propertyConfigurer.setLocation(configResource);
    			return propertyConfigurer;
    		} else {
    			log.warn("configFilePath不存在!");
    		}
    		
    		//如果jar所在目录下有context.properties,则加载
    		String filePath = String.format("file:///%s/%s", userDir, "context.properties");
    		log.info(filePath);
    		org.springframework.core.io.Resource resource =  df.getResource(filePath);
    		if (resource.exists()) {
    			propertyConfigurer.setLocation(resource);
    			return propertyConfigurer;
    		} else {
    			log.warn("filePath不存在!");
    		}
    		
    		//默认加载jar包内的context.properties或如果jar内没有则加载classpath下的context.properties
    		ClassPathResource pathResource = new ClassPathResource("context.properties");
    		propertyConfigurer.setLocation(pathResource);
    		return propertyConfigurer;
    	}
    }
    

    5、增加com.wongoing.config.ReportDataSource.java

    内容如下:

    package com.wongoing.config;
    
    import java.lang.reflect.Field;
    import java.sql.Connection;
    
    import javax.sql.DataSource;
    
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.context.annotation.Configuration;
    
    import com.alibaba.druid.pool.DruidDataSource;
    import com.bstek.ureport.definition.datasource.BuildinDatasource;
    
    import lombok.extern.slf4j.Slf4j;
    
    /**
     * 功能说明:ureport默认数据源配置类
     * 修改说明:
     * @author zheng
     * @date 2022-1-21 9:46:09
     * @version 0.1
     */
    @Configuration
    @Slf4j
    public class ReportDataSource implements BuildinDatasource {
    	
    	/**
    	 * 注入application.yml中的datasource
    	 */
    	@Autowired
    	private DataSource dataSource;
    	
    	@Override
    	public String name() {
    		// TODO Auto-generated method stub
    		String defaultName ="ReportDataSource"; 
    		if (this.dataSource == null) {
    			log.error("注入datasource失败!");
    			return defaultName;
    		} else {
    			if (this.dataSource instanceof DruidDataSource)
    			{
    				String name = "ReportDataSource";
    				DruidDataSource dds = ((DruidDataSource)this.dataSource);
    				try {
    					Field[] fields = dds.getClass().getDeclaredFields();
    					for(Field f : fields) {
    						if (f.getName().equals("basicProperties")) {
    							f.setAccessible(true);					//设置私有属性允许访问
    							Object basicProperties = f.get(dds);
    							Field fieldName = basicProperties.getClass().getDeclaredField("name");
    							if (null != fieldName ) {
    								fieldName.setAccessible(true); 	    //设置私有属性允许访问
    								Object objNameValue = fieldName.get(basicProperties);
    								if (null != objNameValue) {
    									name = objNameValue.toString();
    								}
    							}
    							break;
    						}
    					}
    				} catch(Exception ex) {
    					log.warn("获取name异常");
    				}
    				if (null == name || "".equals(name)) {
    					return defaultName;
    				} else {
    					return name;
    				}
    			} else {
    				return defaultName; 
    			}
    		}
    	}
    
    	@Override
    	public Connection getConnection() {
    		try {
    			return this.dataSource.getConnection();
    		} catch(Exception ex) {
    			System.out.println(ex.getMessage());
    			return null;
    		}
    	}
    }
    
    

    6、启动com.wongoing.ReportServerApplication.java

    内容如下:

    package com.wongoing;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    
    @SpringBootApplication
    public class ReportServerApplication {
    
    	public static void main(String[] args) {
    		SpringApplication.run(ReportServerApplication.class, args);
    	}
    }
    

    7、启动日志

    
      .   ____          _            __ _ _
     /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
    ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
     \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
      '  |____| .__|_| |_|_| |_\__, | / / / /
     =========|_|==============|___/=/_/_/_/
     :: Spring Boot ::                (v2.6.2)
    
    2022-01-21 15:28:10.539  INFO 26048 --- [           main] com.wongoing.ReportApplication           : Starting ReportApplication using Java 1.8.0_311 on zhenglibing-pc with PID 26048 (E:\sts-workspace\ureportdemo\target\classes started by zheng in E:\sts-workspace\ureportdemo)
    2022-01-21 15:28:10.542  INFO 26048 --- [           main] com.wongoing.ReportApplication           : No active profile set, falling back to default profiles: default
    2022-01-21 15:28:11.633  INFO 26048 --- [           main] o.s.c.a.ConfigurationClassEnhancer       : @Bean method ReportConfig.UReportPropertyPlaceholderConfigurer is non-static and returns an object assignable to Spring's BeanFactoryPostProcessor interface. This will result in a failure to process annotations such as @Autowired, @Resource and @PostConstruct within the method's declaring @Configuration class. Add the 'static' modifier to this method to avoid these container lifecycle issues; see @Bean javadoc for complete details.
    2022-01-21 15:28:12.103  INFO 26048 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 9999 (http)
    2022-01-21 15:28:12.115  INFO 26048 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
    2022-01-21 15:28:12.115  INFO 26048 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.56]
    2022-01-21 15:28:12.266  INFO 26048 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
    2022-01-21 15:28:12.266  INFO 26048 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1672 ms
    2022-01-21 15:28:12.337  INFO 26048 --- [           main] c.a.d.s.b.a.DruidDataSourceAutoConfigure : Init DruidDataSource
    2022-01-21 15:28:12.559  INFO 26048 --- [           main] com.alibaba.druid.pool.DruidDataSource   : {dataSource-1} inited
    
    _____  __________ __________________ _______ ________ ______________ 
    __   / / /___  __ \___  ____/___  __ \__  __ \___  __ \___  __/__|__ \
    _  / / / __  /_/ /__  __/   __  /_/ /_  / / /__  /_/ /__  /   ____/ /
    / /_/ /  _  _, _/ _  /___   _  ____/ / /_/ / _  _, _/ _  /    _  __/ 
    \____/   /_/ |_|  /_____/   /_/      \____/  /_/ |_|  /_/     /____/ 
    ........................................................................................................
    .  uReport, is a Chinese style report engine licensed under the Apache License 2.0,                    .
    .  which is opensource, easy to use,high-performance, with browser-based-designer.                     .
    ........................................................................................................
    
    2022-01-21 15:28:14.063  INFO 26048 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 9999 (http) with context path ''
    2022-01-21 15:28:14.075  INFO 26048 --- [           main] com.wongoing.ReportApplication           : Started ReportApplication in 4.033 seconds (JVM running for 5.63)
    
    

    8、打开报表设计器

    在浏览器地址栏输入http://localhost:9999/ureport/designer,显示效果如下:
    在这里插入图片描述

    展开全文
  • UReport2导出报错

    千次阅读 2021-04-25 15:45:42
    UReport2导出报错 问题描述: UReport版本号:2.2.9 简介:导出PDF正常和world是报错,但是导出EXCEL失败,提示:无法访问此网站 网址为 http://ip:8080/fintech/ureport/excel?_u=p 的网页可能暂时无法连接,...

    项目场景:

    UReport2导出报错


    问题描述:

    UReport版本号:2.2.9

    简介:导出PDF正常和world是报错,但是导出EXCEL失败,提示:无法访问此网站 网址为 http://ip:8080/fintech/ureport/excel?_u=p 的网页可能暂时无法连接,或者它已永久性地移动到了新网址。 ERR_INVALID_RESPONSE

    image

    错误日志如下:

    ~~~ Report compute completed:0ms
    java.lang.RuntimeException: java.io.IOException: Permission denied
            at org.apache.poi.xssf.streaming.SXSSFWorkbook.createAndRegisterSXSSFSheet(SXSSFWorkbook.java:688)
            at org.apache.poi.xssf.streaming.SXSSFWorkbook.createSheet(SXSSFWorkbook.java:676)
            at com.bstek.ureport.export.excel.high.builder.ExcelBuilder.createSheet(ExcelBuilder.java:68)
            at com.bstek.ureport.export.excel.high.builder.ExcelBuilderDirect.build(ExcelBuilderDirect.java:68)
            at com.bstek.ureport.export.excel.high.ExcelProducer.doProduce(ExcelProducer.java:45)
            at com.bstek.ureport.export.excel.high.ExcelProducer.produce(ExcelProducer.java:35)
            at com.bstek.ureport.export.ExportManagerImpl.exportExcel(ExportManagerImpl.java:118)
            at com.bstek.ureport.console.excel.ExportExcelServletAction.buildExcel(ExportExcelServletAction.java:99)
            at com.bstek.ureport.console.excel.ExportExcelServletAction.execute(ExportExcelServletAction.java:55)
            at com.bstek.ureport.console.UReportServlet.service(UReportServlet.java:81)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
            at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
            at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:96)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320)
            at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)
            at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilterInternal(BasicAuthenticationFilter.java:158)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter.doFilter(OAuth2AuthenticationProcessingFilter.java:176)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at com.kbd.oct2.config.filter.BackIpfilter.doFilterInternal(BackIpfilter.java:17)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at com.kbd.oct2.config.filter.MyFilter.doFilterInternal(MyFilter.java:40)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:74)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215)
            at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)
            at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357)
            at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
            at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
            at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
            at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
            at org.springframework.session.web.http.SessionRepositoryFilter.doFilterInternal(SessionRepositoryFilter.java:151)
            at org.springframework.session.web.http.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:81)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
            at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
            at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
            at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798)
            at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
            at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
            at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
            at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
            at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
            at java.lang.Thread.run(Thread.java:748)
    Caused by: java.io.IOException: Permission denied
            at java.io.UnixFileSystem.createFileExclusively(Native Method)
            at java.io.File.createTempFile(File.java:2024)
            at org.apache.poi.util.DefaultTempFileCreationStrategy.createTempFile(DefaultTempFileCreationStrategy.java:110)
            at org.apache.poi.util.TempFile.createTempFile(TempFile.java:66)
            at org.apache.poi.xssf.streaming.SheetDataWriter.createTempFile(SheetDataWriter.java:89)
            at org.apache.poi.xssf.streaming.SheetDataWriter.<init>(SheetDataWriter.java:72)
            at org.apache.poi.xssf.streaming.SheetDataWriter.<init>(SheetDataWriter.java:77)
            at org.apache.poi.xssf.streaming.SXSSFWorkbook.createSheetDataWriter(SXSSFWorkbook.java:342)
            at org.apache.poi.xssf.streaming.SXSSFSheet.<init>(SXSSFSheet.java:80)
            at org.apache.poi.xssf.streaming.SXSSFWorkbook.createAndRegisterSXSSFSheet(SXSSFWorkbook.java:684)
            ... 99 more
    15:09:11.783 [http-nio-6380-exec-10] ERROR org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[UReportServlet] - Servlet.service() for servlet [UReportServlet] in context with path [] threw exception
    java.lang.IllegalStateException: getOutputStream() has already been called for this response
            at org.apache.catalina.connector.Response.getWriter(Response.java:583) ~[tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:211) ~[tomcat-embed-core-8.5.39.jar:8.5.39]
            at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:109) ~[tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.springframework.session.web.http.OnCommittedResponseWrapper.getWriter(OnCommittedResponseWrapper.java:150) ~[spring-session-core-2.0.10.RELEASE.jar:2.0.10.RELEASE]
            at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:109) ~[tomcat-embed-core-8.5.39.jar:8.5.39]
            at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:109) ~[tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.springframework.security.web.util.OnCommittedResponseWrapper.getWriter(OnCommittedResponseWrapper.java:149) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at com.bstek.ureport.console.UReportServlet.service(UReportServlet.java:84) ~[ureport2-console-2.2.9.jar:?]
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) ~[tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-embed-websocket-8.5.39.jar:8.5.39]
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:96) ~[spring-web-5.0.13.RELEASE.jar:5.0.13.RELEASE]
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.13.RELEASE.jar:5.0.13.RELEASE]
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101) ~[spring-web-5.0.13.RELEASE.jar:5.0.13.RELEASE]
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilterInternal(BasicAuthenticationFilter.java:158) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.13.RELEASE.jar:5.0.13.RELEASE]
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter.doFilter(OAuth2AuthenticationProcessingFilter.java:176) ~[spring-security-oauth2-2.3.3.RELEASE.jar:?]
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at com.kbd.oct2.config.filter.BackIpfilter.doFilterInternal(BackIpfilter.java:17) ~[biz-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.13.RELEASE.jar:5.0.13.RELEASE]
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at com.kbd.oct2.config.filter.MyFilter.doFilterInternal(MyFilter.java:40) ~[biz-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.13.RELEASE.jar:5.0.13.RELEASE]
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:74) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.13.RELEASE.jar:5.0.13.RELEASE]
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.13.RELEASE.jar:5.0.13.RELEASE]
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) ~[spring-security-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
            at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357) ~[spring-web-5.0.13.RELEASE.jar:5.0.13.RELEASE]
            at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270) ~[spring-web-5.0.13.RELEASE.jar:5.0.13.RELEASE]
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ~[spring-web-5.0.13.RELEASE.jar:5.0.13.RELEASE]
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.13.RELEASE.jar:5.0.13.RELEASE]
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109) ~[spring-web-5.0.13.RELEASE.jar:5.0.13.RELEASE]
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.13.RELEASE.jar:5.0.13.RELEASE]
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) ~[spring-web-5.0.13.RELEASE.jar:5.0.13.RELEASE]
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.13.RELEASE.jar:5.0.13.RELEASE]
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.springframework.session.web.http.SessionRepositoryFilter.doFilterInternal(SessionRepositoryFilter.java:151) ~[spring-session-core-2.0.10.RELEASE.jar:2.0.10.RELEASE]
            at org.springframework.session.web.http.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:81) ~[spring-session-core-2.0.10.RELEASE.jar:2.0.10.RELEASE]
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) ~[spring-web-5.0.13.RELEASE.jar:5.0.13.RELEASE]
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.13.RELEASE.jar:5.0.13.RELEASE]
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) [tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) [tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137) [tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) [tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) [tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798) [tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806) [tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498) [tomcat-embed-core-8.5.39.jar:8.5.39]
            at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.39.jar:8.5.39]
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_181]
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_181]
            at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.39.jar:8.5.39]
            at java.lang.Thread.run(Thread.java:748) [?:1.8.0_181]
    
    

    原因分析:

    项目部署在linux环境下,使用java -jar启动项目的时候,没有使用root账号启动,而是普通管理员账号,所以导致ureport生成临时文件时权限不够

    权限不够的情况:

          1.可能最开始使用root账号启动过,创建了那个临时文件,后来使用普通账号启动,权限不够

           2.可能是原来普通账号权限是够的,但是后来普通账号的权限被限制了


    解决方案:

    使用root启动即可

    同时,对于这种不能下载的,还可能是poi的版本太低,最低要求3.14,参见https://ask.csdn.net/questions/3392787

     

     

     

     

    展开全文
  • Springboot + Ureport

    2021-04-15 15:56:33
    Ureport通过配置生成报表 一、首先创建一个springboot项目,引入包,pom.xml 如下: <?xml version="1.0" encoding="UTF-8"?> <project xmlns=...
  • Ureport2源码启动

    千次阅读 2021-08-31 16:30:05
    由于本人使用的idea,所以接下来...idea导入js项目, ureport2-js 文件。 如下: 导入进来后是没有node_modules文件的 需要使用npm install 下载包。 修改Ureport2-js项目的package.json文件 在scripts中添加 ...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 1,378
精华内容 551
关键字:

uReport