zoukankan      html  css  js  c++  java
  • ModelAndView的部分回顾

                              ModelAndView的部分回顾

    //@RestController @Controller //@SessionAttributes("user") //把modelandview中user attribute对象 拷贝了一份到session的共享控制当中。 public class Test01Controller { // path 和value一样 但是produces = "text/html;charset=utf-8"不能变 @RequestMapping(path = "/mv/{path}.do",produces = "text/html;charset=utf-8") public ModelAndView test(@PathVariable("path") String path){ System.out.println(path); ModelAndView mv = new ModelAndView(); Map map = new HashMap(); map.put("username","admin"); map.put("password","123456"); //一次性添加多个attribute对象 mv.addAllObjects(map); //attribute对象 request mv.addObject("user","username"); //你要跳转到那里 服务器跳转 //也可客户端跳转但是值就不能传递了 mv.setViewName("/success.jsp"); return mv; } @RequestMapping("/m.do") public String test01(@SessionAttribute("user")String user, Integer [] ids){ System.out.println("user:"+user); return "success.jsp"; } @RequestMapping(value = "/lang.do") public String introinfo(HttpServletRequest request, Model model) { Locale locale = RequestContextUtils.getLocaleResolver(request).resolveLocale(request); System.out.println(locale.getLanguage()); //DynamicDataSource.setCurrentLookupKey(locale.getLanguage()); return "success.jsp"; } }
  • 相关阅读:
    记录——framework探测定位程序集与core探测定位程序集
    C# 特定框架适用特定代码
    python读取excel代码
    时间比较
    ORA 01791错误
    MongoDB.1什么是MongoDB
    Mayatis 异常之result maps collection already contains value...
    怎样做好黄焖鸡
    关于foreach
    C#之out,ref关键字
  • 原文地址:https://www.cnblogs.com/chaoesha/p/13069002.html
Copyright © 2011-2022 走看看