基于Spring,Struts2,Hibernate整合,jsp页面导出(下载)excel文件的简单应用1)本例不采用Java任何导出excel文件常用的poi或者jxl等第三方jar包,仅仅基于I/O,做一个最简单的ssh整合excel文件导出(下载)。2)2-3为功能展示a.主页展示·导出当前页到excel文件·导出全部到excel文件b.详细信息展示(下属子地名)·导出当前页到excel文件3)4-7为ssh整合相关xml配置a.Spring相关xml配置b.Hibernate相关xml配置c.Struts2相关xml配置d.web.xml配置(Spring容器的实例化,struts过滤器的配置)3)8-14为源代码a.action代码b.service代码(导出excel文件具体实现,包括下载文件名中文乱码问题,详见代码注释)c.dao代码4)15-17为jsp页面a.index.jsp(主页)b.list.jsp(列表显示)c.detail.jsp(详细信息-子地址列表显示)1.导入相关jar包(ssh+dbcp)2.本例导出全国地址详细信息,数据库中数据内容如下:3.功能展示a.主页b.导出当前页(文件名为当前页起始id到结束id)c.导出当前页的excel文件内容d.导出全部e.下属地名详细信息f.导出下属地名4.spring配置?xmlversion=1.0encoding=UTF-8?beansxmlns=:xsi=:p=:aop=:context=:jee=:tx=:schemaLocation=://://://://://://://://://=dataSourceclass=org.apache.commons.dbcp.BasicDataSourcepropertyname=urlvalue=jdbc:mysql://localhost:3306/photo/propertypropertyname=usernamevalue=root/propertypropertyname=passwordvalue=hl1437/propertypropertyname=driverClassNamevalue=com.mysql.jdbc.Driver/property/beanbeanid=sessionFactoryclass=org.springframework.orm.hibernate3.LocalSessionFactoryBeanpropertyname=dataSourceref=dataSource/propertypropertyname=hibernatePropertiespropspropkey=hibernate.dialectorg.hibernate.dialect.MySQLDialect/proppropkey=hibernate.show_sqltrue/proppropkey=hibernate.format_sqltrue/prop/props/propertypropertyname=mappingResourceslistvaluecom/luo/ssh/entity/Address.hbm.xml/value/list/property/beanbeanid=addressDaoclass=com.luo.ssh.dao.impl.AddressDaoHibernateImplpropertyname=sessionFactoryref=sessionFactory/property/beanbeanid=addressServiceclass=com.luo.ssh.service.impl.AdressServiceImplpropertyname=addressDaoref=addressDao/property/beanbeanid=addressActionclass=com.luo.ssh.action.AddressActionpropertyname=addressServiceref=addressService/property/bean/beans5.hibernate映射配置(基本)?xmlversion=1.0encoding=utf-8?!DOCTYPEhibernate-mappingPUBLIC-//Hibernate/HibernateMappingDTD3.0//EN=com.luo.ssh.entity.Addresstable=addresscatalog=photoidname=idtype=integercolumnname=id/generatorclass=native/generator/idpropertyname=nametype=stringcolumnname=namelength=50//propertypropertyname=leveltype=integercolumnname=level//propertypropertyname=upidtype=integercolumnname=upid//propertypropertyname=infotype=stringcolumnname=info//property/class/hibernate-mapping6.struts配置?xmlversion=1.0encoding=UTF-8?!DOCTYPEstrutsPUBLIC-//ApacheSoftwareFoundation//DTDStrutsConfiguration2.1.7//EN=sshextends=struts-defaultactionname=listclass=addressActionmethod=listparamname=pageSize36/paramresult/list.jsp/result/actionactionname=detailclass=addressActionmethod=detailresult/detail.jsp/result/actionactionname=pageToExcelclass=addressActionmethod=pageToExcel/actionactionname=allToExcelclass=addressActionmethod=allToExcel/actionactionname=childrenToExcelclass=addressActionmethod=childrenToExcel/action/package/struts7.web.xml配置?xmlversion=1.0encoding=UTF-8?web-appversion=2.5xmlns=:xsi=:schemaLocation=://java.sun.com/xml/ns/javaee/web-app_2_5.xsd!--指明spring容器位置--context-paramparam-namecontextConfigLocation/param-nameparam-valueclasspath:ssh.xml/param-value/context-paramlistenerlistener-classorg.springframework.web.context.ContextLoaderListener/listener-class/listenerfilterfilter-namestruts2/filter-namefilter-classorg.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter/filter-class/filterfilter-mappingfilter-namestruts2/filter-nameurl-pattern/*/url-pattern/filter-mappingwelcome-file-listwelcome-fileindex.jsp/welcome-file/welcome-file-list/web-app8.实体类Addresspackagecom.luo.ssh.entity;importjava.io.Serializable;/***地名类*@author罗立明**/publicclassAddressimplementsSerializable{/**地名的id,唯一*/privateintid;/**地名*/privateStringname;/**地名的下属级别,直辖市,省,自治区为1,其他没下一级级别+1*/privateintlevel;/*