程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> exjs-SpringMVC+hibernate4+Extjs4.2+mysql(空指針異常)

exjs-SpringMVC+hibernate4+Extjs4.2+mysql(空指針異常)

編輯:編程綜合問答
SpringMVC+hibernate4+Extjs4.2+mysql(空指針異常)

@ResponseBody
@RequestMapping("/daochu.do")
public Object daochu(String id,HttpServletRequest request)throws Exception{
String ids=id.replaceAll(",", "','");
//System.out.println(ids);
//根據兩個id同時查詢兩條語句
String hql="FROM WorkOrders WHERE id IN ('"+ids+"')";
//String hql="FROM WorkOrders w where w.id=?";
//System.out.println(ids);
System.out.println(id);
Query query=sessionFactory.openSession().createQuery(hql);
//query.setString(0, id);
List list=query.list();
Iterator i=list.iterator();
Workbook wb=new HSSFWorkbook();
Sheet sheet=wb.createSheet("第一個sheet頁");
int m=0;
int n=0;
while(i.hasNext()){
WorkOrders user = (WorkOrders) i.next();
Row row=sheet.createRow(m);
Cell cell1=row.createCell(0);
Cell cell2=row.createCell(1);
Cell cell3=row.createCell(2);
Cell cell4=row.createCell(3);
Cell cell5=row.createCell(4);
Cell cell6=row.createCell(5);
Cell cell7=row.createCell(6);
cell1.setCellValue(user.getId());
cell2.setCellValue(user.getFailuretime());
cell3.setCellValue(user.getFailureaddress());
cell4.setCellValue(user.getRepairtime());
cell5.setCellValue(user.getMaintenanceman());
cell6.setCellValue(user.getCompletion());
cell7.setCellValue(user.getFailurecontent());
m++;
}
String fileName="sss.xls";
String path=request.getSession().getServletContext().getRealPath("/")+"file"+"\"+fileName;// .servletContext.getRealPath("");
System.out.println(path);
//在該位置導出excel文件
//F:\lr_space.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\SpringMVC2\file
FileOutputStream fileOut=new FileOutputStream(path);
wb.write(fileOut);
fileOut.close();
return "success";
}


前台的頁面Extjs
export_Item:function(button){
var grid=button.up('globalStatisticsView')
var data =grid.getSelectionModel().getSelection();
if(data.length==0){
Ext.Msg.alert("提示","您至少選擇一條數據")
}else{
//1.先得到ID的數據(name)
var st=grid.getStore();
var ids=[];
Ext.Array.each(data,function(record){
ids.push(record.get('id'));
});
//2.後台操作
Ext.Ajax.request({
params:{ids:ids.join(",")},
url:'gdgl/daochu.do?id='+ ids,
method:'POST',
timeout:2000,
async:false,
success:function(response,opts){
Ext.Array.each(data,function(record){
st.getById(record);
//st.removeAll(record);
});
}

                    });
                    Ext.Msg.alert("報表成功導出","<font color='green'>報表導出成功!謝謝!<font>");
                }
    },

報出的異常錯誤是:
5,6
十二月 25, 2013 10:57:36 下午 org.apache.catalina.core.StandardWrapperValve invoke
嚴重: Servlet.service() for servlet spring threw exception
java.lang.NullPointerException
at cn.com.cisec.hnjt.control.WorkOrdersController.daochu(WorkOrdersController.java:114)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:643)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
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:103)
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:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)


還有火狐調試的時候發現POST傳值去後台時會發生
POST daochu.do?id=5,6 500 Internal Server Error 127.0.0.1:8080 3.4 KB 127.0.0.1:8080

最佳回答:


我知道了,我的sessionFactory沒有注入
我的session也沒有注入

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved