日期:2014-05-17  浏览次数:20950 次

service注入空指针,求找错!!!
这是action:
Java code
package com.estar.quality.web;

import java.util.HashMap;
import java.util.Map;

import org.apache.struts2.interceptor.RequestAware;
import org.apache.struts2.interceptor.SessionAware;
import org.jfree.chart.JFreeChart;

import com.estar.quality.service.IPersonBaseChartService;
import com.opensymphony.xwork2.ActionSupport;

public class PersonBaseChartAction extends ActionSupport implements RequestAware,
        SessionAware {

    private static final long serialVersionUID = 9183707250741213783L;
    private Map<String, Object> request = new HashMap<String, Object>();
    private Map<String, Object> session = new HashMap<String, Object>();
    private IPersonBaseChartService personBaseChartService;
    private JFreeChart chart;
    
    
    
    //进入列表
    public String getManHistogramList(){
        
        return "ManHistogramList";
    }
    
    //柱状图
    public String getManHistogram(){
        System.out.println("xxxxxxxx");
        System.out.println(personBaseChartService==null);
        try {
            
            this.chart = personBaseChartService.getManHistogram();
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("xxxxxxxx");
        return "jFreeChart";
    }
    
    //饼状图
    public String getManPicChart(){
        
        return null;
    }
    
    //各公司 男女比例
    public String getManTable(){
        
        
        return null;
    }
    
    
    
    public Map<String, Object> getRequest() {
        return request;
    }
    public void setRequest(Map<String, Object> request) {
        this.request = request;
    }
    public Map<String, Object> getSession() {
        return session;
    }
    public void setSession(Map<String, Object> session) {
        this.session = session;
    }
    public JFreeChart getChart() {
        return chart;
    }
    public void setChart(JFreeChart chart) {
        this.chart = chart;
    }

    public IPersonBaseChartService getPersonBaseChartService() {
        return personBaseChartService;
    }

    public void setPersonBaseChartService(
            IPersonBaseChartService personBaseChartService) {
        this.personBaseChartService = personBaseChartService;
    }
}

下面是报错信息:
Java code
xxxxxxxx
true
java.lang.NullPointerException
    at com.estar.quality.web.PersonBaseChartAction.getManHistogram(PersonBaseChartAction.java:36)
    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 com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:440)
    at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:279)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
    at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:163)
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
    at com.opensymphony.xw