org.springframework.ui.Model.addAllAttributes()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(491)

本文整理了Java中org.springframework.ui.Model.addAllAttributes()方法的一些代码示例,展示了Model.addAllAttributes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Model.addAllAttributes()方法的具体详情如下:
包路径:org.springframework.ui.Model
类名称:Model
方法名:addAllAttributes

Model.addAllAttributes介绍

[英]Copy all attributes in the supplied Collection into this Map, using attribute name generation for each element.
[中]使用为每个元素生成属性名的方法,将提供的集合中的所有属性复制到此映射中。

代码示例

代码示例来源:origin: spring-projects/spring-framework

@Override
public DefaultRenderingBuilder modelAttributes(Object... values) {
  initModel().addAllAttributes(Arrays.asList(values));
  return this;
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public DefaultRenderingBuilder model(Map<String, ?> map) {
  initModel().addAllAttributes(map);
  return this;
}

代码示例来源:origin: cloudfoundry/uaa

protected void populateBuildAndLinkInfo(Model model) {
  Map<String, Object> attributes = new HashMap<String, Object>();
  model.addAllAttributes(attributes);
}

代码示例来源:origin: xuxueli/xxl-job

@RequestMapping("/")
public String index(Model model) {
  Map<String, Object> dashboardMap = xxlJobService.dashboardInfo();
  model.addAllAttributes(dashboardMap);
  return "index";
}

代码示例来源:origin: stylefeng/Guns

/**
 * 跳转到修改通知
 *
 * @author fengshuonan
 * @Date 2018/12/23 6:06 PM
 */
@RequestMapping("/notice_update/{noticeId}")
public String noticeUpdate(@PathVariable Long noticeId, Model model) {
  Notice notice = this.noticeService.selectById(noticeId);
  model.addAllAttributes(BeanUtil.beanToMap(notice));
  LogObjectHolder.me().set(notice);
  return PREFIX + "notice_edit.html";
}

代码示例来源:origin: spring-projects/spring-framework

model.addAllAttributes(render.modelAttributes());
Object view = render.view();
if (view == null) {
model.addAllAttributes(((Model) returnValue).asMap());
viewsMono = resolveViews(getDefaultViewName(exchange), locale);
model.addAllAttributes((Map<String, ?>) returnValue);
viewsMono = resolveViews(getDefaultViewName(exchange), locale);

代码示例来源:origin: stylefeng/Guns

/**
 * 跳转到查看用户详情页面
 *
 * @author fengshuonan
 * @Date 2018/12/24 22:43
 */
@RequestMapping("/user_info")
public String userInfo(Model model) {
  Long userId = ShiroKit.getUserNotNull().getId();
  User user = this.userService.selectById(userId);
  model.addAllAttributes(BeanUtil.beanToMap(user));
  model.addAttribute("roleName", ConstantFactory.me().getRoleName(user.getRoleId()));
  model.addAttribute("deptName", ConstantFactory.me().getDeptName(user.getDeptId()));
  LogObjectHolder.me().set(user);
  return PREFIX + "user_view.html";
}

代码示例来源:origin: miyakowork/NoteBlog

@GetMapping
public String index(Model model) {
  List<XParam> params = paramRepository.findAll();
  Map<String, Object> attributeMap = params.stream().collect(Collectors.toMap(XParam::getName, XParam::getValue));
  model.addAllAttributes(attributeMap);
  return "management/settings";
}

代码示例来源:origin: xuxueli/xxl-mq

@RequestMapping("/")
public String index(Model model, HttpServletRequest request) {
  Map<String, Object> dashboardMap = xxlMqMessageService.dashboardInfo();
  model.addAllAttributes(dashboardMap);
  return "index";
}

代码示例来源:origin: weiqingwen/spring-boot-forum

@RequestMapping(value = "", method = RequestMethod.GET)
public String getHomePostsByPage(Model model, 
    @RequestParam(value = "p", required = false, defaultValue="1") Integer pageNum,
    @RequestParam(value = "size", required = false, defaultValue="10") Integer pageSize) {
  Map<String, Object> attributes = this.postService.findPostsByPage(pageNum, pageSize);
  if (null == attributes) {
    return "error/404";
  }
  model.addAllAttributes(attributes);
  return "forum/home";
}

代码示例来源:origin: weiqingwen/spring-boot-forum

@RequestMapping(value = "/category/{categoryName}", method = RequestMethod.GET)
public String getCategoryPostsByPage(@PathVariable String categoryName, Model model,
    @RequestParam(value = "p", required = false) Integer pageNum) {
  if (null == categoryName) {
    return "error/404";
  }
  int currPage = pageNum == null ? 1 : pageNum;
  Map<String, Object> attributes = this.postService.findPostsListByCategoryByPage(categoryName, currPage,
      pageSize);
  if (null == attributes) {
    return "error/404";
  }
  model.addAllAttributes(attributes);
  return "forum/home";
}

代码示例来源:origin: weiqingwen/spring-boot-forum

@PreAuthorize("hasAuthority('ADMIN')")
@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
public String getDashboardPage(Model model, @RequestParam(value = "tab", required = false) String tab,
    @RequestParam(value = "start", required = false) String start,
    @RequestParam(value = "end", required = false) String end) {
  Map<String, Object> attributes = this.dashboardService.getDashboard(tab, start, end);
  if (null == attributes) {
    throw new ResourceNotFoundException("attributes not found.");
  }
  model.addAllAttributes(attributes);
  model.addAttribute("tab", tab);
  model.addAttribute("start", start);
  model.addAttribute("end", end);
  return "forum/dashboard";
}

代码示例来源:origin: chanjarster/spring-mvc-error-handling-example

@ExceptionHandler(AnotherException.class)
String handleAnotherException(HttpServletRequest request, HttpServletResponse response, Model model)
  throws IOException {
 // 需要设置Status Code,否则响应结果会是200
 response.setStatus(601);
 model.addAllAttributes(errorAttributes.getErrorAttributes(new ServletRequestAttributes(request), true));
 return "error/6xx";
}

代码示例来源:origin: weiqingwen/spring-boot-forum

@RequestMapping(value = "/new", method = RequestMethod.GET)
public String displayNewPostPage(Model model) {
  Map<String, Object> attributes = this.categoryService.getNewPostPageWithCategorySelect();
  if (null == attributes) {
    throw new ResourceNotFoundException("attributes not found.");
  }
  model.addAllAttributes(attributes);
  return "forum/new-post";
}

代码示例来源:origin: weiqingwen/spring-boot-forum

@RequestMapping(value = "/user/settings", method = RequestMethod.GET)
public String showUserSettingsPage(Model model) {
  Map<String, Object> attributes = this.userService.getUserSettingPage();
  if (null == attributes) {
    throw new ResourceNotFoundException("attributes not found.");
  }
  model.addAllAttributes(attributes);
  return "forum/user-settings";
}

代码示例来源:origin: weiqingwen/spring-boot-forum

@RequestMapping(value = "/user/registration-confirm", method = RequestMethod.GET)
public String confirmRegistration(@RequestParam("token") String token, Model model) {
  if (null == token || token.equals("")) {
    throw new BadRequestException("Invalid user registration confirmation token.");
  }
  Map<String, Object> attributes = this.userService.confirmUserRegistrationWithToken(token);
  if (null == attributes) {
    throw new ResourceNotFoundException("attributes not found.");
  }
  model.addAllAttributes(attributes);
  return "forum/user-registration-confirm";
}

代码示例来源:origin: weiqingwen/spring-boot-forum

@RequestMapping(value = "/user/{userId}", method = RequestMethod.GET)
public String showUserProfilePage(@RequestParam(value = "tab", required = false) String tabType,
    @PathVariable Long userId, Model model) {
  if (null == userId) {
    throw new BadRequestException("Path variable userId cound not be null.");
  }
  Map<String, Object> attributes = this.userService.getUserProfileAndPostsByUserIdByTabType(userId, tabType);
  if (null == attributes) {
    throw new ResourceNotFoundException("attributes not found.");
  }
  model.addAllAttributes(attributes);
  return "forum/user-profile";
}

代码示例来源:origin: weiqingwen/spring-boot-forum

@RequestMapping(value = "/new/{categoryName}", method = RequestMethod.GET)
public String displayNewPostPageWithCategory(Model model, @PathVariable String categoryName) {
  if (null == categoryName) {
    throw new BadRequestException("Path variable postId cound not be null.");
  }
  Map<String, Object> attributes = this.categoryService.getNewPostPageWithCategoryName(categoryName);
  if (null == attributes) {
    throw new ResourceNotFoundException("attributes not found.");
  }
  model.addAllAttributes(attributes);
  return "forum/new-post";
}

代码示例来源:origin: weiqingwen/spring-boot-forum

@RequestMapping(value = "/user/settings", method = RequestMethod.POST)
public String handleFileUpload(@ModelAttribute("userSettingsDto") UserSettingsDto userSettingsDto, Model model) {
  if (null == userSettingsDto) {
    throw new BadRequestException("UserSettingsDto cound not be null.");
  }
  Map<String, Object> attributes = this.userService.updateUserProfile(userSettingsDto);
  if (null == attributes) {
    throw new ResourceNotFoundException("attributes not found.");
  }
  model.addAllAttributes(attributes);
  return "forum/user-settings";
}

代码示例来源:origin: weiqingwen/spring-boot-forum

@RequestMapping(value = "/post/{postId}", method = RequestMethod.GET)
public String getPost(Model model, @PathVariable Long postId) {
  if (null == postId) {
    throw new BadRequestException("Path variable postId cound not be null.");
  }
  Map<String, Object> attributes = this.postService.findPostDetailsAndCommentsByPostId(postId);
  if (null == attributes) {
    throw new ResourceNotFoundException("attributes not found.");
  }
  model.addAllAttributes(attributes);
  return "forum/post";
}

相关文章

微信公众号

最新文章

更多