浏览 8788 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2007-08-01
我用的是 WebWork+freemarker。 工程里 web.xml文件里配置了相关过滤器: <filter> <filter-name>eXtremeExport</filter-name> <filter-class>org.extremecomponents.table.filter.ExportFilter</filter-class> </filter> <filter-mapping> <filter-name>eXtremeExport</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <context-param> <param-name>extremecomponentsPreferencesLocation</param-name> <param-value>/conf/extremetable.properties</param-value> </context-param> extremetable.properties文件: #table.filterable=false table.filterable=false table.imagePath=/extremecomponents/images/*.gif table.locale=zh_CN table.view.html=org.extremecomponents.table.view.CompactView table.rowsDisplayed=15 row.highlightRow=true table.view.freemarker=com.wonderad.table.view.FreeMarkerView column.format.date=yyyy-MM-dd HH:mm:ss column.format.currency=###,###,###,###,#00.00 用于显示的页面文件是: listuser.ftl <link href="/styles/extremecomponents.css" type="text/css" rel="stylesheet"> <#assign ec=JspTaglibs["/extremecomponents/extremecomponents.tld"] /> <table width="100%" border="1" cellspacing="1" cellpadding="1" bordercolor="white"> <tr><td> <div align="center" > <font color="#FF9900">显示用户:</font> <@ec.table items="listuser" var="lu" action="./listuser.do" width="600" > <@ec.exportXls fileName="listuser.xls" tooltip="Export Excel"/> <@ec.row> <@ec.column property="rowcount" cell="rowCount" title="序号" sortable="false"/> <@ec.column property="userName" title="用户名"/> <@ec.column property="passWord" title="密码"/> <@ec.column property="email" title="Email"/> <@ec.column property="assetsValue" title="修改"> <a href="retrieveuser.do?model.userId=${lu.userId?if_exists}">修改</a></@ec.column> <@ec.column property="assetsValue" title="删除"> <a href="deleteuser.do?model.userId=${lu.userId?if_exists}" onclick="return(confirm('确认删除吗?'))" >删除</a></@ec.column> </@ec.row> </@ec.table> </td></tr> <tr><a href="adduser!input.do">ADD</a></tr> </table> 如果在xwork.xml里加入拦截器,如下: <action name="listuser" class="org.personnal.action.user.ListAllUserAction"> <interceptor-ref name="i18n"/> <interceptor-ref name="params" /> <interceptor-ref name="model-driven"/> <result type="freemarker" name="success"> /WEB-INF/ftl/user/userlist.ftl </result> </action> 如果有拦截器的话,在点导出Excel的时候不会弹出保存文件的提示框,页面变成空白页,控制台没有任何错误信息。 如果把xwork.xml里拦截器去掉 <action name="listuser" class="org.personnal.action.user.ListAllUserAction"> <result type="freemarker" name="success"> /WEB-INF/ftl/user/userlist.ftl </result> </action> 控制台就会报错: 23:16:21.031 INFO [SocketListener0-1] com.opensymphony.webwork.views.freemarker.FreemarkerManager.getInstance(FreemarkerManager.java:118) >30> Instantiating Freemarker ConfigManager!, com.opensymphony.webwork.views.freemarker.FreemarkerManager 23:16:26.125 ERROR! [SocketListener0-1] com.opensymphony.xwork.util.CompoundRootAccessor.setProperty(CompoundRootAccessor.java:68) >33> No object in the CompoundRoot has a publicly accessible property named 'ec_crd' (no setter could be found). 23:16:26.125 ERROR! [SocketListener0-1] com.opensymphony.xwork.util.OgnlValueStack.setValue(OgnlValueStack.java:168) >26> Error setting expr 'ec_crd' with value '[Ljava.lang.String;@e5355f' No object in the CompoundRoot has a publicly accessible property named 'ec_crd' (no setter could be found). - [unknown location] at com.opensymphony.xwork.util.CompoundRootAccessor.setProperty(CompoundRootAccessor.java:69) at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:1629) at ognl.ASTProperty.setValueBody(ASTProperty.java:105) at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177) at ognl.SimpleNode.setValue(SimpleNode.java:246) at ognl.Ognl.setValue(Ognl.java:476) at com.opensymphony.xwork.util.OgnlUtil.setValue(OgnlUtil.java:186) ............ 23:16:26.187 ERROR! [SocketListener0-1] com.opensymphony.xwork.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:146) >24> Developer Notification (set webwork.devMode to false to disable this message): No object in the CompoundRoot has a publicly accessible property named 'ec_crd' (no setter could be found). 23:16:26.203 ERROR! [SocketListener0-1] com.opensymphony.xwork.util.CompoundRootAccessor.setProperty(CompoundRootAccessor.java:68) >33> No object in the CompoundRoot has a publicly accessible property named 'ec_efn' (no setter could be found). 23:16:26.203 ERROR! [SocketListener0-1] com.opensymphony.xwork.util.OgnlValueStack.setValue(OgnlValueStack.java:168) >26> Error setting expr 'ec_efn' with value '[Ljava.lang.String;@143bf3d' No object in the CompoundRoot has a publicly accessible property named 'ec_efn' (no setter could be found). - [unknown location] at com.opensymphony.xwork.util.CompoundRootAccessor.setProperty(CompoundRootAccessor.java:69) at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:1629) at ognl.ASTProperty.setValueBody(ASTProperty.java:105) at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177) at ognl.SimpleNode.setValue(SimpleNode.java:246) at ognl.Ognl.setValue(Ognl.java:476) at com.opensymphony.xwork.util.OgnlUtil.setValue(OgnlUtil.java:186) 错误信息很长,没有全贴出来,后面也是诸如下面这样的的信息: No object in the CompoundRoot has a publicly accessible property named 'ec_i' (no setter could be found). - [unknown location] No object in the CompoundRoot has a publicly accessible property named 'ec_s_userName' (no setter could be found). No object in the CompoundRoot has a publicly accessible property named 'ec_s_assetsValue' (no setter could be found). 不知道问题出在哪里,这问题困扰了我2天,在网上也查了好久,还是找不到原因.有人可以帮我看一下吗,是我少包还是配置问题啊,检查了很久都找不到问题所在,这里先谢谢了。在附件里放了这个工程的压缩包,所有的JAR包也在里面。url:http://localhost:8080/user/listuser.do 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2007-08-02
没人遇到过这种问题吗? 如果实在不行就只好用POI或者JXL了
补充一下,服务期器的是 jetty-5.1 [img]http://brucezheng.iteye.com/upload/picture/pic/4524/4ce6e9c7-c0da-4d86-b253-5949e8a2388d.jpg [/img] |
|
返回顶楼 | |
发表时间:2007-08-02
搞清楚了,是web.xml的问题。把extremeTable的过滤器放在WebWork的过滤器上面就可以了,试了很多次,就是这个原因。
无法导出时的web.xml文件: <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>Personnal</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath*:applicationContext.xml classpath*:/**/dao/ibatis/applicationContext-*.xml, classpath*:/**/service/applicationContext-*.xml, </param-value> </context-param> <filter> <filter-name>webwork-cleanup</filter-name> <filter-class>com.opensymphony.webwork.dispatcher.ActionContextCleanUp</filter-class> </filter> <filter> <filter-name>webwork</filter-name> <filter-class>com.opensymphony.webwork.dispatcher.FilterDispatcher</filter-class> </filter> <filter-mapping> <filter-name>webwork-cleanup</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>webwork</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- Character Encoding filter --> <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <!-- Webwork 展示用,FreeMarker支持taglib的用到servlet --> <servlet> <servlet-name>JspSupportServlet</servlet-name> <servlet-class> com.opensymphony.webwork.views.JspSupportServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <!-- ExtremeTable 表格标签的Properties文件 --> <context-param> <param-name>extremecomponentsPreferencesLocation</param-name> <param-value>/conf/extremetable.properties</param-value> </context-param> <!-- ExtremeTable 导出Excel和Pdf的Filter --> <filter> <filter-name>eXtremeExport</filter-name> <filter-class>org.extremecomponents.table.filter.ExportFilter</filter-class> </filter> <filter-mapping> <filter-name>eXtremeExport</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!--Spring ApplicationContext 载入 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- session超时定义,单位为分钟 --> <session-config> <session-timeout>10</session-timeout> </session-config> <!-- 默认首页定义 --> <welcome-file-list> <welcome-file>index.htm</welcome-file> <welcome-file>index.html</welcome-file> </welcome-file-list> </web-app> 修改后的可以成功导出时的web.xml文件: <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>Personnal</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath*:applicationContext.xml classpath*:/**/dao/ibatis/applicationContext-*.xml, classpath*:/**/service/applicationContext-*.xml, </param-value> </context-param> <!-- ExtremeTable 表格标签的Properties文件 --> <context-param> <param-name>extremecomponentsPreferencesLocation</param-name> <param-value>/conf/extremetable.properties</param-value> </context-param> <!-- ExtremeTable 导出Excel和Pdf的Filter --> <filter> <filter-name>eXtremeExport</filter-name> <filter-class>org.extremecomponents.table.filter.ExportFilter</filter-class> </filter> <filter-mapping> <filter-name>eXtremeExport</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> <filter-name>webwork-cleanup</filter-name> <filter-class>com.opensymphony.webwork.dispatcher.ActionContextCleanUp</filter-class> </filter> <filter> <filter-name>webwork</filter-name> <filter-class>com.opensymphony.webwork.dispatcher.FilterDispatcher</filter-class> </filter> <filter-mapping> <filter-name>webwork-cleanup</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>webwork</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- 著名 Character Encoding filter --> <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <!-- Webwork 展示用,FreeMarker支持taglib的用到servlet --> <servlet> <servlet-name>JspSupportServlet</servlet-name> <servlet-class> com.opensymphony.webwork.views.JspSupportServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <!--Spring ApplicationContext 载入 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- session超时定义,单位为分钟 --> <session-config> <session-timeout>10</session-timeout> </session-config> <!-- 默认首页定义 --> <welcome-file-list> <welcome-file>index.htm</welcome-file> <welcome-file>index.html</welcome-file> </welcome-file-list> </web-app> 只是过滤器的顺序发生变化,代码都是一样的。为什么会这样不是很清楚了,应该和加载顺序有关。 另外,控制台的异常信息,只要把webwork.properties文件里的 webwork.devMode = true 改为: webwork.devMode = false 就没有控制台的异常信息了。 |
|
返回顶楼 | |