IT序号网

spring MVC利用注解直接返回Json

leader 2021年06月13日 编程语言 300 0
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 { 
	 
	@Autowired 
	SlaveDbService slaveDbService; 
	 
	 
	@RequestMapping(value = "/slaveEvent", method = RequestMethod.GET) 
	@ResponseBody 
	@JsonGetter 
	public List<Event> test(){ 
		 
		List<Event> list=slaveDbService.getSlaveEvent(null); 
		 
		return list; 
		 
	}	 
	 
} 


评论关闭
IT序号网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!