⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 export_filter.apt

📁 一个比较不错的java分页标签,有源代码,开发者 可以学习学习
💻 APT
字号:
                                    ------------------------------
                                            Export filter
                                    ------------------------------
                                          Fabrizio Giustina
                                    ------------------------------
                                              26-11-2005
                                    ------------------------------

Export filter? What's that?

 When displaytag exports data in any non-html format, it needs to change the content type returned to the
 browser and reset any other content generated by the surrounding page.

 Sometimes this can't be done: if content has already been sent back to the user, the response can't be
 reset and you get an error. This could happen because:


 * Too many chars have been already written to the response, so that the response buffer was full and response
 has been automatically flushed.

 * Something (tags? java snippets?) before the <<<display:table>>> tag has explicitely flushed the response
 (<<<response.flushBuffer()>>>).

 * Your page is dinamically included into another page. This happens for example using Struts tiles.

 []


 Another problem is related to exporting binary files. The output of binary data is not supported in
jsps: it may work on some application server, but it may end up with errors in others. Because of this
restriction an "external help" may be required. Cvs, xml and excel formats don't require a binary
output, but if you want to try a pdf export or other custom binary formats you will have to face some
problems.


* The solution

 The first attempt can be using a larger page buffer in your jsp pages, for example:
 <<<&lt;%@ page buffer = "16kb" %&gt;>>>
 However, this can work only if you are in the first situation listed above.

 In j2ee 1.3/jsp 1.2 containers you can take advantage of filters to solve the problem. Displaytag ships
 with a filter which works together with the table tag during export, disallowing the response to be
 flushed when an export has been requested.



* Installing the export filter

 Configure the Filter in your web.xml:

+--------------------------------------------------------+
  <filter>
    <filter-name>ResponseOverrideFilter</filter-name>
    <filter-class>org.displaytag.filter.ResponseOverrideFilter</filter-class>
  </filter>
+--------------------------------------------------------+

 And add mappings for the pages that you will intercept, for example:

+--------------------------------------------------------+
  <filter-mapping>
    <filter-name>ResponseOverrideFilter</filter-name>
    <url-pattern>*.do</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>ResponseOverrideFilter</filter-name>
    <url-pattern>*.jsp</url-pattern>
  </filter-mapping>
+--------------------------------------------------------+

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -