81,122
社区成员




import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import co.jp.nec.controller.common.MulipartFileController;
import co.jp.nec.model.SDA_MA_DaichoTeigi_A;
import co.jp.nec.model.common.SDA_MZ_Message;
import co.jp.nec.serviceImp.CommonService;
import co.jp.nec.serviceImp.SDAA.AlldataacquisitionEquipmentSer;
2012/03/16 10:28:03 org.apache.catalina.core.StandardWrapperValve invoke
致命的: サーブレット appServlet のServlet.service()が例外を投げました
java.lang.NoClassDefFoundError: org/apache/poi/hssf/usermodel/HSSFWorkbook
at co.jp.nec.controller.SDAA.AllDataAcquisitionEquipmentController.fileUpLoad(AllDataAcquisitionEquipmentController.java:148)
at co.jp.nec.controller.SDAA.AllDataAcquisitionEquipmentController.upload(AllDataAcquisitionEquipmentController.java:206)
at co.jp.nec.controller.SDAA.AllDataAcquisitionEquipmentController.checkReference(AllDataAcquisitionEquipmentController.java:99)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:212)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
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:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
package co.jp.nec.controller.SDAA;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import co.jp.nec.controller.common.MulipartFileController;
import co.jp.nec.model.SDA_MA_DaichoTeigi_A;
import co.jp.nec.model.common.SDA_MZ_Message;
import co.jp.nec.serviceImp.CommonService;
import co.jp.nec.serviceImp.SDAA.AlldataacquisitionEquipmentSer;
@Controller
public class AllDataAcquisitionEquipmentController {
private Log log = LogFactory.getLog(MulipartFileController.class);
private String SDA_BumonCD;
@Autowired
private CommonService commonService;
@Autowired
private AlldataacquisitionEquipmentSer alldataacquisitionEquipmentSer;
@RequestMapping(value = "/addUser")
public String addUser() {
return "SDAG/addUser";
}
/**
* test 跳转
*
* @param request
* @param model
* @return
*/
@RequestMapping(value = "doAddUser", method = RequestMethod.POST)
public String addUserSuccuss(HttpServletRequest request, ModelMap model) {
return "SDAA/GSDAA050";
}
/**
* 点击参照按钮事件处理
*
* @param request
* @param model
* @return
*/
@RequestMapping(value = "checkReference", method = RequestMethod.POST)
public String checkReference(HttpServletRequest request, ModelMap model,
@RequestParam(value = "file") MultipartFile multipartFile) {
ArrayList list = new ArrayList<SDA_MA_DaichoTeigi_A>();
SDA_BumonCD = new String();
System.out.println("this is a test message!");
SDA_MZ_Message message = new SDA_MZ_Message();
String fileAcquisition = request.getParameter("hd3");
File file = new File(fileAcquisition);
System.out.println(file.exists());
System.out.println(fileAcquisition.matches(".*\\.(?i)xls"));
// System.out.println("".length());
if (fileAcquisition == "") {
// message = commonService.getMessageById("COM_W_005");
message.setSDA_Messgae("不能为空!");
// System.out.println(message);
model.put("message", message);
return "SDAA/GSDAA050";
}
if (file.exists() && file.isFile()) {
if (fileAcquisition.matches(".*\\.(?i)xls")
|| fileAcquisition.matches(".*\\.(?i)xlsx")) {
System.out.println(fileAcquisition);
try {
upload(model, request, multipartFile, file);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (SDA_BumonCD == "10") {
list = alldataacquisitionEquipmentSer
.selectSDA_MA_DaichoTeigi_A(SDA_BumonCD);
}
if (SDA_BumonCD == "20") {
list = alldataacquisitionEquipmentSer
.selectSDA_MA_DaichoTeigi_B(SDA_BumonCD);
}
if (SDA_BumonCD == "30") {
list = alldataacquisitionEquipmentSer
.selectSDA_MA_DaichoTeigi_C(SDA_BumonCD);
}
if (SDA_BumonCD == "40") {
list = alldataacquisitionEquipmentSer
.selectSDA_MA_DaichoTeigi_D(SDA_BumonCD);
}
if (SDA_BumonCD == "50") {
list = alldataacquisitionEquipmentSer
.selectSDA_MA_DaichoTeigi_E(SDA_BumonCD);
}
return "SDAA/GSDAA050";
}
}
else {
/** 所选文件类型不匹配! */
// message = commonService.getMessageById("COM_W_005");
message.setSDA_Messgae("该路径不存在!");
model.put("message", message);
return "SDAA/GSDAA050";
}
return "SDAA/GSDAA050";
}
void fileUpLoad(File file, MultipartFile multipartFile) {
List<String[]> list = new ArrayList<String[]>();
try {
InputStream is = multipartFile.getInputStream();
is = new FileInputStream(file);
HSSFWorkbook workbook = new HSSFWorkbook(is);
HSSFSheet sheet = workbook.getSheetAt(0);
int rows = sheet.getLastRowNum() + 1 - sheet.getFirstRowNum();
for (int i = 0; i < rows; i++) {
HSSFRow hssfRow = sheet.getRow(i);
int cols = hssfRow.getLastCellNum() + 1
- hssfRow.getFirstCellNum();
String[] str = new String[cols];
for (int j = 0; j < cols; j++) {
Object col = hssfRow.getCell((short) j);
Object colNext = hssfRow.getCell((short) (j + 1));
if (col != null) {
str[j] = col.toString();
} else {
if (colNext != null) {
Object colValue = "";
colValue.toString();
}
}
list.add(str);
}
}
} catch (Exception e) {
// TODO: handle exception
}
for (int i = 0; i < list.size(); i++) {
String[] str = list.get(i);
for (int j = 0; j < str.length; j++) {
System.out.println(str[j]);
}
}
}
public String upload(ModelMap model, HttpServletRequest request,
MultipartFile multipartFile, File file1) throws Exception {
System.out.println("this is a message!");
log.info(multipartFile.getName());
String uploadName = multipartFile.getOriginalFilename();// 上传文件名
String ctxPath = "D:/upload/";
File file = new File(ctxPath);
if (!file.exists()) {
file.mkdir();
}
File uploadFile = new File(ctxPath + uploadName);
FileCopyUtils.copy(multipartFile.getBytes(), uploadFile);
// multipartFile.transferTo(file);
model.put("emssage", "success!!!");
System.out.println("__________________________________");
fileUpLoad(file1, multipartFile);
return "SDAA/GSDAA050";
}
}