我在运行以下代码时获得了deviceService的null值?

时间:2015-10-07 06:53:56

标签: spring jsf

这是控制器类的代码,在运行deviceService时返回null值。 deviceService应该从服务类返回控制器中的一些值。

 @ManagedBean
    @ViewScoped
    public class DeviceController implements Serializable {

        private Device device;
        private List<Device> deviceList;

        @ManagedProperty("#{deviceService}")
        public DeviceService deviceService;

    /**
         * @return the deviceService
         */
        public DeviceService getDeviceService() {
            return deviceService;
        }

        /**
         * @param deviceService the deviceService to set
         */
        public void setDeviceService(DeviceService deviceService) {
            this.deviceService = deviceService;

        }

这是deviceService类代码

@Service("deviceService")
@Transactional(readOnly = true)
public class DeviceService {

    @Autowired
    IDeviceDao iDevice;

    @Transactional(readOnly = false)
    public void addDevice(Device device) {
        iDevice.addDevice(device);
    }

    public List<Device> getDeviceList() {
        return iDevice.getDeviceList();
    }

    @Transactional(readOnly = false)
    public void deleteDevice(Device device) {
        iDevice.deleteDevice(device);
    }
}

0 个答案:

没有答案