zoukankan      html  css  js  c++  java
  • 数据返回(数据共享,即从后端返回到前端调用,四种(requesst、ModelAndView、Model、Map))

    @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";
    		}
    }
    

      

  • 相关阅读:
    iOS6和iOS7代码的适配(5)——popOver
    es5创建对象与继承
    js学习日记-new Object和Object.create到底干了啥
    js滚动及可视区域的相关的操作
    css匹配规则及性能
    normalize.css源码分析
    css的水平居中和垂直居中总结
    js快速排序算法
    数据结构flash演示
    二叉树遍历
  • 原文地址:https://www.cnblogs.com/1020182600HENG/p/6891682.html
Copyright © 2011-2022 走看看