码迷,mamicode.com
首页 > 其他好文 > 详细

数据返回(数据共享,即从后端返回到前端调用,四种(requesst、ModelAndView、Model、Map))

时间:2017-05-22 23:08:59      阅读:441      评论:0      收藏:0      [点我收藏+]

标签:四种   dsa   ppi   log   str   add   print   mvc   control   

@Controller
@RequestMapping("/view")//请求父路径
public class GoodsController {

		@RequestMapping("/goodsReturnReq.do")//请求子路径
		public String goodsReturnReq(Goods goods,HttpServletRequest request){
			System.out.println("goodsReturnReq:"+goods);
			request.setAttribute("gds",goods);
			//MySpringMVC02/view/goodsAddOk.jsp  注意:404错误一般都是路径写错了,须仔细检查哪里拼写错了
			//MySpringMVC02/view/goodsAddOK.jsp  这里K一个大写一个小写
			return "goodsAddOK";//请求成功的返回路径
		}
		
		@RequestMapping("/goodsReturnMav.do")
		public ModelAndView goodsReturnMav(Goods goods){
			System.out.println("goodsReturnMav:"+goods);
			ModelAndView mav = new ModelAndView("goodsAddOK");//请求成功的返回路径
			mav.addObject("gds",goods);
			return mav;//返回模型视图
		}
		
		@RequestMapping("goodsReturnModel.do")
		public String goodsReturnModel(Goods goods,Model model){
			System.out.println("goodsReturnModel:"+goods);
			model.addAttribute("gds",goods);//此处是add不是set
			return "goodsAddOK";
		}
		
		@RequestMapping("goodsReturnMap")
		public String goodsReturnMap(Goods goods,Map map){
			System.out.println("goodsReturnMap:"+goods);
			map.put("gds", goods);//Map
			return "goodsAddOK";
		}
}

  

数据返回(数据共享,即从后端返回到前端调用,四种(requesst、ModelAndView、Model、Map))

标签:四种   dsa   ppi   log   str   add   print   mvc   control   

原文地址:http://www.cnblogs.com/1020182600HENG/p/6891682.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!