java - springmvc uses modelandview to redirect to a requestmapping and carries an object type parameter.
阿神
阿神 2017-06-12 09:23:19
0
1
892
请输入代码 ModelAndView mv = new ModelAndView( "redirect:/add_shopping_cart_success.do");//这个是重定向到的请求 // formcart是需要传递的对象参数 mv.addObject(formcart); return mv; } @RequestMapping("add_shopping_cart_success") public String add_shopping_cart_success(T_MALL_SHOPPINGCAR formcart, HttpSession session, ModelMap map) { // 用formcart 接不到

Please enter the code ModelAndView mv = new ModelAndView(

"redirect:/add_shopping_cart_success.do");//这个是重定向到的请求 // 这样传的话下面能接到 就是会在浏览器显示所有参数 mv.addObject("sku_mch",formcart.getSku_mch()); mv.addObject("sku_jg",formcart.getSku_jg()); mv.addObject("sku_tp",formcart.getShp_tp()); mv.addObject("tjshl",formcart.getTjshl()); mv.addObject("shp_id",formcart.getShp_id()); mv.addObject("sku_id",formcart.getSku_id()); return mv;

}

@RequestMapping("add_shopping_cart_success") public String add_shopping_cart_success(T_MALL_SHOPPINGCAR formcart, HttpSession session, ModelMap map) {
阿神
阿神

闭关修行中......

reply all (1)
伊谢尔伦

Method 1: Manually splice urls by yourself

new ModelAndView("redirect:/toList?param1="+value1+"¶m2="+value2); 这样有个弊端,就是传中文可能会有乱码问题。 方式二:用RedirectAttributes,这个是发现的一个比较好用的一个类 这里用它的addAttribute方法,这个实际上重定向过去以后你看url,是它自动给你拼了你的url。 使用方法: attr.addAttribute("param", value); return "redirect:/namespace/toController"; 这样在toController这个方法中就可以通过获得参数的方式获得这个参数,再传递到页面。过去的url还是和方式一一样的。
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!