首页>代码>spring mvc返回新闻的json数据列表>/SpringMVC/src/com/lzh/controller/JsonController.java
package com.lzh.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author Administrator 测试json数据 1 使用拼装 string 方法 然后通过response返回
 */
@Controller
@RequestMapping("/json")
public class JsonController {

	@RequestMapping("/json3")
	@ResponseBody
	public  List<News> json3(String username, HttpServletResponse resp) throws IOException {
		List<News> newsList = new ArrayList<News>();
		for(int i=0;i<10;i++){
			News news=new News("我的天","孙悟空","中国新闻","2017-09-09");
			newsList.add(news);
		}
		return newsList;
	}
	
}
最近下载更多
雪白透亮  LV6 2022年5月16日
dingdehong  LV10 2020年9月27日
李兰香  LV11 2019年12月28日
13940562934  LV22 2019年11月13日
hanxinjie  LV25 2019年11月7日
zk2323  LV3 2019年9月8日
小资李  LV13 2019年7月26日
SDDDONG  LV11 2019年5月3日
嘻嘻哈哈123  LV4 2019年2月21日
小明1234567  LV6 2018年8月25日
最近浏览更多
975525508  LV1 2023年6月5日
ljx0617  LV1 2022年11月18日
zhenghan  LV1 2022年6月25日
xzyyzyl 2022年6月3日
暂无贡献等级
雪白透亮  LV6 2022年5月16日
兰文斌  LV6 2022年4月27日
xxxhhh1314  LV7 2022年1月9日
3455123870  LV7 2021年12月20日
nsz123456  LV11 2021年12月11日
孤寂的靛蓝示波极谱仪  LV2 2021年12月8日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友