java.lang.Error: Unresolved compilation problems:
ServletActionContext cannot be resolved
The type List is not generic; it cannot be parameterized with arguments
Syntax error, parameterized types are only available if source level is 5.0
ArrayList cannot be resolved to a type
Syntax error, parameterized types are only available if source level is 5.0
The type List is not generic; it cannot be parameterized with arguments
Syntax error, parameterized types are only available if source level is 5.0
ArrayList cannot be resolved to a type
Syntax error, parameterized types are only available if source level is 5.0
ActionContext cannot be resolved
SysConstant cannot be resolved
log cannot be resolved
filePath cannot be resolved
filePath cannot be resolved
Constants cannot be resolved
carInsModificationFacade cannot be resolved
filePath cannot be resolved
Constants cannot be resolved
FacadeException cannot be resolved to a type
e cannot be resolved
e cannot be resolved
The type List is not generic; it cannot be parameterized with arguments
Syntax error, parameterized types are only available if source level is 5.0
The type List is not generic; it cannot be parameterized with arguments
Syntax error, parameterized types are only available if source level is 5.0
FacadeException cannot be resolved to a type
log cannot be resolved
InputStream cannot be resolved to a type
FileInputStream cannot be resolved to a type
Workbook cannot be resolved to a type
Workbook cannot be resolved
Sheet cannot be resolved to a type
The type List is not generic; it cannot be parameterized with arguments
Syntax error, parameterized types are only available if source level is 5.0
ArrayList cannot be resolved to a type
Syntax error, parameterized types are only available if source level is 5.0
CarInsModificationInfo cannot be resolved to a type
CarInsModificationInfo cannot be resolved to a type
StringUtils cannot be resolved
Pattern cannot be resolved
Pattern cannot be resolved
carInsModificationDAO cannot be resolved
carInsModificationDAO cannot be resolved
StringUtils cannot be resolved
StringUtils cannot be resolved
StringUtils cannot be resolved
StringUtils cannot be resolved
carInsModificationDAO cannot be resolved
CmodiType cannot be resolved to a type
CmodiType cannot be resolved to a type
StringUtils cannot be resolved
StringUtils cannot be resolved
Date cannot be resolved to a type
DateFormater cannot be resolved
DateFormater cannot be resolved
Date cannot be resolved to a type
carInsModificationDAO cannot be resolved
FacadeException cannot be resolved to a type
log cannot be resolved
at util.ExcelServlet.<init>(ExcelServlet.java:40)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1104)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:806)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
2009-3-29 3:51:38 org.apache.catalina.core.StandardWrapperValve invoke
信息: Servlet ExcelServlet is currently unavailable
代码是:
public class ExcelServlet extends HttpServlet {
public ExcelServlet() {
super();
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
File file = new File("C:/adminexcel.xls");
try {
System.out.println(read(file));
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
public static String read(File file) throws Exception {
StringBuffer sb = new StringBuffer();
Workbook wb = null;
try {
wb = Workbook.getWorkbook(file);
if (wb != null) {
Sheet[] sheets = wb.getSheets();
if (sheets != null && sheets.length != 0) {
for (int i=0;i<sheets.length;i++) {
int rows = sheets[i].getRows();
for (int j=0;j<rows;j++) {
Cell[] cells = sheets[i].getRow(j);
if (cells != null && cells.length != 0) {
for (int k=0;k<cells.length;k++) {
String cell = cells[k].getContents();
System.out.println(cell);
sb.append(cell + "\t");
}
sb.append("\t\n");
}
}
sb.append("\t\n");
}
}
System.out.println("成功" + file + "\n");
}
} catch (Exception e) {
System.out.println(e.getMessage());
} finally {
wb.close();
}
return sb.toString();
}
}