一直说“int newsid = Integer.parseInt(request.getParameter("newsid"));”有问题啊
这个是我action:
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
ModifyForm modifyForm = (ModifyForm) form;
// TODO Auto-generated method stub
int newsid = Integer.parseInt(request.getParameter("newsid"));
List list = new ArrayList();
NewDAO newDAO = new NewDAO();
int i = 0;
list = newDAO.shownews(newsid);
request.setAttribute("main",list);
// return mapping.findForward("success");
System.out.println(modifyForm);
System.out.println("修改的是:"+newsid+"号");
i = newDAO.modifynews(modifyForm,newsid);
if(i == 1){
System.out.println("成功转入");
return mapping.findForward("success");
}else{
System.out.println("不成功转入");
return mapping.findForward("failure");
}
}
下面是写的DAO里面的:
public int modifynews(ModifyForm form,int id){
int record = 0;
System.out.println("要修改的ID号:"+id);
PreparedStatement ps = null;
String sql = "update NEWS set TOPIC = ?,CONTENT = ? where NEWS_ID = ?";
try {
ps = conn.prepareStatement(sql);
ps.setString(1,form.getTopic());
ps.setString(2,form.getContent());
ps.setInt(3,id);
record = ps.executeUpdate();
System.out.println("修改成功");
} catch (SQLException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
System.out.println("修改失败");
}
return record;
}
下面是报的错:
修改的是:2号
要修改的ID号:2
修改成功
成功转入
2006-11-5 19:35:15 org.apache.struts.action.RequestProcessor processException
警告: Unhandled Exception thrown: class java.lang.NumberFormatException
2006-11-5 19:35:15 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet action threw exception
java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Integer.java:415)
at java.lang.Integer.parseInt(Integer.java:497)
at com.thinkbank.zhengh.struts.action.ModifyAction.execute(ModifyAction.java:49)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at com.thinkbank.zhengh.filter.NewsFilter.doFilter(NewsFilter.java:24)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
我自己把一些有问题的地方打印出来了,打印表明我要传入的id已经传入成功了
但是还是一直都报“int newsid = Integer.parseInt(request.getParameter("newsid"));”
小菜鸟初学JAVA 调了一下午还没调出来,请高人指点,不胜感激
[此贴子已经被作者于2006-11-8 0:26:08编辑过]