servlet如下:
String path = request.getContextPath();
String title = request.getParameter("title");
String digest = request.getParameter("digest");
String body = request.getParameter("body");
String source = request.getParameter("source");
String time = request.getParameter("time");
List<Object> params = new ArrayList<Object>();
params.add(title);
params.add(digest);
params.add(body);
params.add(source);
params.add(time);
for(Iterator<Object> it = params.iterator();it.hasNext();){
String str = (String) it.next();
System.out.println(str);
}
boolean flag = service.addNews(params);
if(flag){
response.sendRedirect(path + "/servlet/ProductAction?action_flag=list");
}
//boolean flag = service.addNews(params);
//if(!flag){
//service.addNews(params);
//System.out.println("success");
//response.sendRedirect(path + "/servlet/ProductAction?action_flag=list");
}
标红的代码总是不能执行,为什么呢?不为什么,service是空,抛nullpointerexception呗
楼主程序执行的时候有没有报什么异常? 报的异常是什么?贴出来看看。