spring mvc 中如何传值

2025-05-04 02:23:08

1、session传值,通过request获取session,然后通过session的方法获取绑定值@RequestMapping("/customTest.do")public String customTest(HttpServletRequest request,String name,String phone){HttpSession session = request.getSession();

spring mvc 中如何传值

2、Custom c = customDao.findOne(phone, name);session.setAttribute("custom",c);session.setAttribute("phone", phone);return "redirect:customTest1.do";}session属于会话期间的传值,

spring mvc 中如何传值

3、/** * 接收页面传递参数,插入数据库,并跳转列表 * @param sell * @param model * @return */model传值,通过数据模型传值,这种传值属于request传值,一次请求期间的传值;

spring mvc 中如何传值

4、@RequestMapping("/insertSell.do")public String insertSell(SellInfo sell,Model model){sellService.insert(sell);model.addAttribute("sell", sell);return "redirect:/login/sell.do";}

spring mvc 中如何传值
spring mvc 中如何传值

5、@RequestMapping(&孥恶膈茯quot;/sellList.do")public ModelAndView sellL足毂忍珩ist(@RequestParam("id")Long id,ModelAndView mv){mv.addObject("user", u);mv.setViewName("sellList");return mv;}modelAndView传值,视图模型传值,绑定视图名称传值;

spring mvc 中如何传值

6、实体对象接受数据,进行传值,保证jsp页面中input标签中name属性与实体对象的属性一致,即可使吹涡皋陕用实体对象接收jsp页面的数据;@RequestMapping("/insertSell.do")public String insertSell(SellInfo sell,Model model){sellService.insert(sell);return "redirect:/login/sell.do";}

spring mvc 中如何传值
spring mvc 中如何传值
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
相关推荐
  • 阅读量:30
  • 阅读量:72
  • 阅读量:40
  • 阅读量:35
  • 阅读量:37
  • 猜你喜欢