2013年9月15日星期日

About springMVC redirected to the page parameter passing problem

Before I had looked on the Internet , although there are answers to find some blog , but I put the code copy down , or did not pass parameters success.


@ RequestMapping ("/ queryBrandById")
public ModelAndView queryBrandById (int id) {
Map map = new HashMap ();
/ / received parameter id is to find information about this id
Brand brand = brandDAOIMPL.queryBrandById (id);
map.put ("brand", brand);
return new ModelAndView ("redirect :/ queryBrandByIdSuc.jsp", map);

}


This brand is a value object , I want to brand this object is output to queryBrandIdSuc.jsp page,
I use EL expressions show $ {brand} parameter brand but not
------ Solution ---------- ----------------------------------
return new ModelAndView ("redirect :/ queryBrandByIdSuc. jsp? brand = "+ brand)
------ For reference only ----------------------------- ----------
@ RequestMapping ("/ queryBrandById")
public ModelAndView queryBrandById (int id, Model model) {
Map map = new HashMap ();
/ / received parameter id is to find information about this id
Brand brand = brandDAOIMPL.queryBrandById (id);
/ / map.put ("brand", brand);
model.addAttribute ("brand", brand);

return "queryBrandByIdSuc.jsp";
/ / return new ModelAndView ("redirect :/ queryBrandByIdSuc.jsp", map);

}

------ For reference only ---------------------------------- -----
Thank you for your reply , but did not achieve the effect I want , ah, I want to redirect the client to jump .
------ For reference only -------------------------------------- -
title already said wow way to pass parameters to use redirection . . .
------ For reference only -------------------------------------- -
Thank you, problem solved
------ For reference only ----------------------------- ----------
me to turn over the code stickers, convenience there is a need to look

@ RequestMapping ("/ queryBrandById")
public ModelAndView queryBrandById (int id) {
/ / received parameter id is to find information about this id
Brand brand = brandDAOIMPL.queryBrandById (id);
String str = brand.getName ();
return new ModelAndView ("redirect :/ queryBrandByIdSuc.jsp? brand =" + brand + "str =" + str);
}

which is passed two parameters, the front desk jsp page using $ {param.brand}, $ {param.str} can receive

没有评论:

发表评论