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"; } }
  • 相关阅读:
    error: <item> inner element must either be a resource reference or empty.
    PEM routines:PEM_read_bio:no start line
    Android Https双向认证 + GRPC
    git tag用法
    Linux文件查找
    Detected problems with API compatibility(visit g.co/dev/appcompat for more info)
    Android NDK开发调试
    Beyond-Compare 4 -linux 破解
    Ubuntu下Gradle环境配置
    多线程系列一
  • 原文地址:https://www.cnblogs.com/chaoesha/p/13069002.html
Copyright © 2011-2022 走看看