1、log4j
需要jar
commons-logging.jar log4j-1.2.16.jar
需要配置文件
log4j.properties文件 log4j.rootLogger=DEBUG,stdout #log4j.logger.com.pzhu.jams.cmt=DEBUG,A1 log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout # Pattern to output the caller's file name and line number. #log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n # Print the date in ISO 8601 format log4j.appender.stdout.layout.ConversionPattern=%d{HH:mm:ss} %p - %%%F:%L%% [--%m--]%n #log4j.appender.db=org.apache.log4j.jdbc.JDBCAppender #log4j.appender.db.BufferSize=1 #log4j.appender.db.driver=com.mysql.jdbc.Driver #log4j.appender.db.URL=jdbc:mysql://localhost:3306/cmtsys?useUnicode=true&characterEncoding=utf8 #log4j.appender.db.user=root #log4j.appender.db.password=123456 #log4j.appender.db.sql=insert into cmt_log(user_id,user_type,time,desc) values ('%X{user_id}','%X{user_role}','%d{yyyy-MM-dd HH\:mm\:ss}','%m') #log4j.appender.db.layout=org.apache.log4j.PatternLayout #log4j.appender.A1=org.apache.log4j.RollingFileAppender #log4j.appender.A1.File=${webapp.root}/WEB-INF/logs/org.log #log4j.appender.A1.MaxFileSize=500KB #log4j.appender.A1.MaxBackupIndex=50 #log4j.appender.A1.Append=true #log4j.appender.A1.layout=org.apache.log4j.PatternLayout #log4j.appender.A1.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} - [%p] [%C{1}] - %m%n # Print only messages of level info or above in the package com.pzhu.jams.cmt #log4j.logger.com.pzhu.jams.cmt=INFO log4j.logger.com.ibatis=OFF log4j.logger.org.mybatis.spring=OFF log4j.logger.org.apache.ibatis=OFF log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=OFF log4j.logger.com.ibatis.common.jdbc.ScriptRunner=OFF log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=OFF log4j.logger.java.sql.Connection=OFF log4j.logger.java.sql.Statement=DEBUG log4j.logger.java.sql.PreparedStatement=DEBUG log4j.logger.java.sql.ResultSet=DEBUG log4j.logger.org.springframework=OFF web.xml配置
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:log4j.properties</param-value> </context-param>
<!--Spring log4j Config listener-->
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
类里面写
protected Logger logger = Logger.getLogger(BaseController.class);ok了
2、jsp调用润乾报表
jar(简单使用(查看,导出)不需要jar) 授权文件(runqianReportLog.properties) 制作的报表模板
配置文件
reportConfig.xml文件 <?xml version="1.0" encoding="UTF-8" ?> <reportConfig> <config> <name>logConfig</name> <value>runqianReportLog.properties</value> </config> <config> <name>license</name> <value>runqianWindowServer.lic</value> </config> <config> <name>reportFileHome</name> <value>/runqian/reportFiles</value> </config> <config> <name>semanticsFile</name> <value></value> </config> <config> <name>JNDIPrefix</name> <value>java:comp/env</value> </config> <!-- JNDI数据源配置,格式:数据源的JNDI名称,数据库类型[,取数时是否需要转换编码,数据库字符集编码,显示报表时的字符集编码][,SQL是否需要转码];[重复]…… <config> <name>dataSource</name> <value>jdbc/test,oracle;exercise,sqlsvr,1,iso8859-1,GBK,0;</value> </config> --> <config> <name>jspCharset</name> <value>UTF-8</value> </config> <config> <name>alwaysReloadDefine</name> <value>yes</value> </config> <config> <name>cachedParamsTimeout</name> <value>10</value> </config> <config> <name>cachedReportDir</name> <value>work\report\cached</value> </config> <config> <name>cachedIdPrefix</name> <value>A</value> </config> <config> <name>cachedReportTimeout</name> <value>10</value> </config> <config> <name>maxCellNum</name> <value>1000000</value> </config> <config> <name>maxConcurrentForReport</name> <value>10</value> </config> <config> <name>maxWaitForReport</name> <value>10</value> </config> <config> <name>maxWaitTimeForReport</name> <value>30</value> </config> <config> <name>appUrlPrefix</name> <value></value> </config> <config> <name>windir</name> <value></value> </config> <config> <name>errorPage</name> <value>/myErrorPage.jsp</value> </config> <config> <name>webServerType</name> <value></value> </config> <config> <name>jreInstallName</name> <value></value> </config> <config> <name>jreVersion</name> <value></value> </config> <config> <name>clusterMember</name> <value></value> </config> <config> <name>isCachedFileShared</name> <value></value> </config> <config> <name>olapGraphProfile</name> <value></value> </config> <config> <name>olapDir</name> <value></value> </config> <jdbc-ds-configs> <jdbc-ds-config> <name>cmtsys</name> <db-type>mysql</db-type> <connection-url>jdbc:mysql://localhost:3306/cmtsys</connection-url> <driver-class>com.mysql.jdbc.Driver</driver-class> <user-name>root</user-name> <password>123456</password> <db-charset>GBK</db-charset> <client-charset>GBK</client-charset> <extend-properties></extend-properties> </jdbc-ds-config> <jdbc-ds-config> <name>orcl</name> <db-type>oracle</db-type> <connection-url>jdbc:oracle:thin:@127.0.0.1:1521:orcl</connection-url> <driver-class>oracle.jdbc.driver.OracleDriver</driver-class> <user-name>pxs</user-name> <password>123456</password> <db-charset>GBK</db-charset> <client-charset>GBK</client-charset> <extend-properties></extend-properties> </jdbc-ds-config> </jdbc-ds-configs> </reportConfig> runqianReportLog.properties文件 //æ¥å¿çº§å«å¯ä¸ºOFF,ERROR,WARN,INFO,DEBUG,ALL, ä¼å 级ä¾æ¬¡éä½ï¼è¥ä¸ºOFFåä¸è¾åºä»»ä½ //æ¥å¿ä¿¡æ¯ï¼è¥ä¸ºINFOï¼ååªè¾åºERROR,WARN,INFOç级å«çä¿¡æ¯ï¼ä¾æ¬¡ç±»æ¨ã log4j.logger.runqianReportLogger=DEBUG,LOG1,LOG2 //è¾åºæ¥å¿å°ç³»ç»æ§å¶å° log4j.appender.LOG1=org.apache.log4j.ConsoleAppender log4j.appender.LOG1.layout=org.apache.log4j.PatternLayout log4j.appender.LOG1.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss}] %c : [%-5p] %x - %m%n //è¾åºæ¥å¿å°æå®æ件 log4j.appender.LOG2=org.apache.log4j.RollingFileAppender //å¯ä»¥æå®LOG2.Fileçå ¨è·¯å¾, è¥æªææï¼å为ç¸å¯¹WEBæå¡å¨å¯å¨æ件çè·¯å¾ log4j.appender.LOG2.File=runqianReport.log log4j.appender.LOG2.Append=true //æ¥å¿æ件çæ大åèæ° log4j.appender.LOG2.MaxFileSize=10MB //æ¥å¿æ件çæå¤å¤ä»½æ° log4j.appender.LOG2.MaxBackupIndex=1 log4j.appender.LOG2.layout=org.apache.log4j.PatternLayout log4j.appender.LOG2.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss}] %c : [%-5p] %x - %m%n web.xml配置 <servlet> <servlet-name>reportServlet</servlet-name> <servlet-class>com.runqian.report4.view.ReportServlet</servlet-class> <init-param> <param-name>configFile</param-name> <param-value>/WEB-INF/classes/reportConfig.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>reportServlet</servlet-name> <url-pattern>/reportServlet</url-pattern> </servlet-mapping>
调用:window.location.href=Base.contextPath + "/runqian/reportJsp/showReport.jsp?raq=cmt1&user_id=jams";注意带上模板需要的参数
3、解析excel、txt文本为bean(公司集成的)
jar
dom4j-1.6.1.jar(或者jdom-1.1.3.jar或者都要,我忘了) jxl-2.6.12.jar ta3-sysframework-3.12.0.jar ta3-fileexceltools-3.12.0.jar当然了,后面的是公司的,网上没有
配置文件(不需要)
调用
首先得得到上传的文件(不属于解析模块哈)
上传文件 jsp中 <input type="file" name="file" id="file" style="display: inline-block;"> <input type="submit" class="btn btn-primary sure" value="导入"> 控制器中 public String importExcel(MultipartFile file) throws Exception{ logger.info("导入用户信息"); InputStream fin = file.getInputStream(); List list= ExcelFileUtils.getExcelInputStream2ObjectList(fin, "user_id,user_name,user_password,user_gender_desc,user_age,user_type_desc,user_dept_desc,user_addr", "com.pzhu.jams.cmt.entity.User", true); //HashMap map = getParams(); userService.parseAndInsertUser(list); return "user_list"; } web.xml好像不配置
解析:
上面控制器里已有了
List list= ExcelFileUtils.getExcelInputStream2ObjectList(fin, "user_id,user_name,user_password,user_gender_desc,user_age,user_type_desc,user_dept_desc,user_addr", "com.pzhu.jams.cmt.entity.User", true);
-----将file得到的流通过excelFileUtils(txt用另外一个utils)解析excel列到user_id...等bean属性,然后就可以遍历list查看了