回 帖 发 新 帖 刷新版面

主题:java.lang.NullPointerException

哪位大哥知道我错在哪里了谢谢

Search76Action.java

package com;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class Search76Action extends Action {
        public ActionForward execute(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response) {
        Search76Form search76Form = (Search76Form) form;// TODO Auto-generated method stub
        String sheng = search76Form.getSheng();
        String emini = search76Form.getEmini();
        String smini = search76Form.getSmini();
        String regdate2 = search76Form.getRegdate2();
        String regdate = search76Form.getRegdate();
        String stime=regdate+" "+smini+":00:00";
        String etime=regdate2+" "+emini+":00:00";


               ArrayList arr = new ArrayList();
                arr.add(sheng);
                arr.add(stime);
                arr.add(etime);

                String prompt=null;
                try {
               //调用模型组件Search76Handler
                    if(sheng.equals("AllCountry")){
                    Search76Handler Search76 = new Search76Handler();
                    boolean mark = Search76.checkAllCountry(arr);

                    if(mark)  prompt = "search76Success";                
                      else prompt = "search76Fail";   
                    
                    System.out.println(prompt);
                }else{
                    Search76Handler Search76 = new Search76Handler();
                    boolean mark = Search76.checkSheng(arr);

                    if(mark)  prompt = "search76Success";                
                      else prompt = "search76Fail";   
                    
                    System.out.println(prompt);
                    
                }
                    
                } catch (Exception e) {
                    e.printStackTrace();
                }        
                    
                return mapping.findForward(prompt);        
    }

}

------------------这是结果------------------    
search76Success
java.lang.NullPointerException
    at com.Search76Action.execute(Search76Action.java:58)
    at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
    at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
    at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
    at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
    at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
    at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
    at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
    at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
    at com.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:105)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:793)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:702)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:571)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:644)
    at java.lang.Thread.run(Unknown Source)
2007-11-5 20:40:25 org.apache.struts.action.ActionMapping findForward
警告: Unable to find 'null' forward.

回复列表 (共3个回复)

沙发


请问这个初值该在哪里赋,我打印出来的怎么都是空的

板凳


怎么就没人回呢
[em19]

3 楼

?页面和struts-config都没有问题吗?

我来回复

您尚未登录,请登录后再回复。点此登录或注册