spring MVC利用注解直接返回Json

来源:互联网 发布:2017淘宝发货时间规定 编辑:程序博客网 时间:2024/06/05 15:53
package com.jt.report.scheduler;import java.util.List;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.scheduling.annotation.Scheduled;import org.springframework.stereotype.Component;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.bind.annotation.ResponseBody;import com.fasterxml.jackson.annotation.JsonGetter;import com.jt.report.entity.Event;import com.jt.report.service.SlaveDbService;@Component@RequestMapping("/test")public class ReportJobForTest {@AutowiredSlaveDbService slaveDbService;@RequestMapping(value = "/slaveEvent", method = RequestMethod.GET)@ResponseBody@JsonGetterpublic List<Event> test(){List<Event> list=slaveDbService.getSlaveEvent(null);return list;}}

0 0
原创粉丝点击