Java Code Examples for org.springframework.ui.Model#addAllAttributes()

The following examples show how to use org.springframework.ui.Model#addAllAttributes() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IndexController.java    From DouBiNovel with Apache License 2.0 7 votes vote down vote up
@RequestMapping("/book/detail")
public String detail(String url, Model model) {
    MvcResult result = bookAnalysisService.loadBookDetail(url);
    if (!result.isSuccess()) {
        model.addAttribute("msg", result.getMessage());
        return "public/error";
    }
    model.addAllAttributes(result.getValues());


    Subject subject = SecurityUtils.getSubject();
    User user = (User) subject.getPrincipal();
    if (user != null) {
        BookInfo bookInfo = bookInfoService.getBookInfoByBookUrlAndUser(url, user);
        if (bookInfo != null) {
            if (StringUtils.isNotBlank(bookInfo.getLastReadCatalogLink())) {
                model.addAttribute("lastReadCatalogLink", bookInfo.getLastReadCatalogLink());
                model.addAttribute("lastReadCatalogName", bookInfo.getLastReadCatalogName());
            }
        }
    }
    return "front/book/detail";
}
 
Example 2
Source File: PersonBean.java    From init-spring with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "/edit", method = RequestMethod.POST)
public String submitEdit(@Valid Person person, BindingResult bindingResult, Model model)
{
	log.debug("edit person={}", person);
	if (bindingResult.hasErrors())
	{
		log.warn("validation error={}", bindingResult.getModel());
		model.addAllAttributes(bindingResult.getModel());
		return "person/form";
	}
	this.personRepository.save(person);
	return "redirect:/person/list";
}
 
Example 3
Source File: LoginController.java    From Guns with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 跳转到主页
 *
 * @author fengshuonan
 * @Date 2018/12/23 5:41 PM
 */
@RequestMapping(value = "/", method = RequestMethod.GET)
public String index(Model model) {

    //判断用户是否登录
    if (LoginContextHolder.getContext().hasLogin()) {
        Map<String, Object> userIndexInfo = userService.getUserIndexInfo();

        //用户信息为空,提示账号没分配角色登录不进去
        if (userIndexInfo == null) {
            model.addAttribute("tips", "该用户没有角色,无法登陆");
            return "/login.html";
        } else {
            model.addAllAttributes(userIndexInfo);
            return "/index.html";
        }

    } else {
        return "/login.html";
    }
}
 
Example 4
Source File: TblMonitorController.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
    * Shows tra StudentChoices page
    */
   @RequestMapping("/traStudentChoices")
   public String traStudentChoices(@RequestParam(name = AttributeNames.PARAM_TOOL_CONTENT_ID) long toolContentId,
    Model model) throws IOException, ServletException {
Scratchie scratchie = scratchieService.getScratchieByContentId(toolContentId);

Map<String, Object> modelAttributes = scratchieService.prepareStudentChoicesData(scratchie);
model.addAllAttributes(modelAttributes);

model.addAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID, toolContentId);
return "pages/monitoring/studentChoices";
   }
 
Example 5
Source File: NoticeController.java    From Guns with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 跳转到修改通知
 *
 * @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.getById(noticeId);
    model.addAllAttributes(BeanUtil.beanToMap(notice));
    LogObjectHolder.me().set(notice);
    return PREFIX + "notice_edit.html";
}
 
Example 6
Source File: SystemController.java    From Guns with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 跳转到查看用户详情页面
 *
 * @author fengshuonan
 * @Date 2018/12/24 22:43
 */
@RequestMapping("/user_info")
public String userInfo(Model model) {
    Long userId = LoginContextHolder.getContext().getUserId();
    User user = this.userService.getById(userId);

    model.addAllAttributes(BeanUtil.beanToMap(user));
    model.addAttribute("roleName", ConstantFactory.me().getRoleName(user.getRoleId()));
    model.addAttribute("deptName", ConstantFactory.me().getDeptName(user.getDeptId()));
    model.addAttribute("avatar", DefaultImages.defaultAvatarUrl());
    LogObjectHolder.me().set(user);

    return "/modular/frame/user_info.html";
}
 
Example 7
Source File: SettingsController.java    From yyblog with MIT License 5 votes vote down vote up
@GetMapping
public String index(Model model) {
    List<SettingDO> settings = settingService.listAll();
    Map<String, Object> attributeMap = new HashMap<String, Object>();
    for (SettingDO setting : settings) {
        attributeMap.put(setting.getCode(), setting.getValue());
    }
    model.addAllAttributes(attributeMap);
    return "management/settings";
}
 
Example 8
Source File: SettingsController.java    From NoteBlog with MIT License 5 votes vote down vote up
@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";
}
 
Example 9
Source File: PersonBean.java    From init-spring with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/form", method = RequestMethod.POST)
public String save(@Valid Person person, BindingResult bindingResult, Model model)
{
	log.info("create person {}", person);
	if (bindingResult.hasErrors())
	{
		log.info("Error:{}", bindingResult.getModel());
		model.addAllAttributes(bindingResult.getModel());
		return "/person/form";
	}
	personRepository.save(person);
	return "redirect:/person/list";
}
 
Example 10
Source File: IndexController.java    From xxl-job with GNU General Public License v3.0 5 votes vote down vote up
@RequestMapping("/")
public String index(Model model) {

	Map<String, Object> dashboardMap = xxlJobService.dashboardInfo();
	model.addAllAttributes(dashboardMap);

	return "index";
}
 
Example 11
Source File: IndexController.java    From xxl-mq with GNU General Public License v3.0 5 votes vote down vote up
@RequestMapping("/")
public String index(Model model, HttpServletRequest request) {

	Map<String, Object> dashboardMap = xxlMqMessageService.dashboardInfo();
	model.addAllAttributes(dashboardMap);

	return "index";
}
 
Example 12
Source File: ModelUtil.java    From layui-admin with MIT License 5 votes vote down vote up
/**
 * 填充Model
 * @param model Model
 * @param resBean 待填充的信息
 * */
public static String fillModelAndReturnView(Model model,ModelView resBean){
      log.info("View Model填入参数:{}",resBean);
      //填充model并返回视图
      if(!resBean.getAttributes().isEmpty()){
          model.addAllAttributes(resBean.getAttributes());
      }

      return resBean.getReturnView();
}
 
Example 13
Source File: LooController.java    From spring-mvc-error-handling-example with Apache License 2.0 5 votes vote down vote up
@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";
}
 
Example 14
Source File: IndexController.java    From zuihou-admin-boot with Apache License 2.0 5 votes vote down vote up
@RequestMapping("/")
public String index(Model model) {

    Map<String, Object> dashboardMap = xxlJobService.dashboardInfo();
    model.addAllAttributes(dashboardMap);

    return "index";
}
 
Example 15
Source File: IndexController.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
@RequestMapping("/")
public String index(Model model) {

	Map<String, Object> dashboardMap = xxlJobService.dashboardInfo();
	model.addAllAttributes(dashboardMap);

	return "index";
}
 
Example 16
Source File: GoodsController.java    From leyou with Apache License 2.0 5 votes vote down vote up
/**
 * 跳转到商品详情页
 *
 * @param model
 * @param id
 * @return
 */
@GetMapping("/{id}.html")
public String toItemPage(Model model, @PathVariable("id") Long id) {
    // 加载所需的数据
    Map<String, Object> modelMap = this.goodsService.loadModel(id);
    // 放入模型
    model.addAllAttributes(modelMap);
    // 页面静态化
    this.goodsHtmlService.asyncExcute(id);

    return "/item";
}
 
Example 17
Source File: IndexController.java    From xmfcn-spring-cloud with Apache License 2.0 4 votes vote down vote up
@RequestMapping("/")
public String index(Model model) {
    Map<String, Object> dashboardMap = xxlJobService.dashboardInfo();
    model.addAllAttributes(dashboardMap);
    return "index";
}
 
Example 18
Source File: YsController.java    From dbys with GNU General Public License v3.0 4 votes vote down vote up
@ModelAttribute
public void bif(Model model) {
    model.addAllAttributes(comm.getAllComm());
}
 
Example 19
Source File: OAuth2Controller.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@GetMapping( "/confirm_access" )
public String confirmAccess( Model model, @RequestParam Map<String, String> rpParameters )
{
    model.addAllAttributes( rpParameters );
    return "confirm_access";
}
 
Example 20
Source File: MonitoringController.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@RequestMapping("/summary")
   private String summary(HttpServletRequest request, Model model) {

// initialize Session Map
SessionMap<String, Object> sessionMap = new SessionMap<>();
request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap);
model.addAttribute(ScratchieConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID());

Long contentId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID);
List<GroupSummary> summaryList = scratchieService.getMonitoringSummary(contentId);

Scratchie scratchie = scratchieService.getScratchieByContentId(contentId);
Set<ScratchieUser> learners = scratchieService.getAllLeaders(contentId);

//set SubmissionDeadline, if any
if (scratchie.getSubmissionDeadline() != null) {
    Date submissionDeadline = scratchie.getSubmissionDeadline();
    HttpSession ss = SessionManager.getSession();
    UserDTO teacher = (UserDTO) ss.getAttribute(AttributeNames.USER);
    TimeZone teacherTimeZone = teacher.getTimeZone();
    Date tzSubmissionDeadline = DateUtil.convertToTimeZoneFromDefault(teacherTimeZone, submissionDeadline);
    model.addAttribute(ScratchieConstants.ATTR_SUBMISSION_DEADLINE, tzSubmissionDeadline.getTime());
    model.addAttribute(ScratchieConstants.ATTR_SUBMISSION_DEADLINE_DATESTRING,
	    DateUtil.convertToStringForJSON(submissionDeadline, request.getLocale()));
}

// cache into sessionMap
boolean isGroupedActivity = scratchieService.isGroupedActivity(contentId);
sessionMap.put(ScratchieConstants.ATTR_IS_GROUPED_ACTIVITY, isGroupedActivity);
sessionMap.put(ScratchieConstants.ATTR_SUMMARY_LIST, summaryList);
sessionMap.put(ScratchieConstants.ATTR_SCRATCHIE, scratchie);
sessionMap.put(ScratchieConstants.ATTR_LEARNERS, learners);
sessionMap.put(ScratchieConstants.ATTR_TOOL_CONTENT_ID, contentId);
sessionMap.put(AttributeNames.PARAM_CONTENT_FOLDER_ID,
	WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID));
sessionMap.put(ScratchieConstants.ATTR_REFLECTION_ON, scratchie.isReflectOnActivity());

// Create BurningQuestionsDtos if BurningQuestions is enabled.
if (scratchie.isBurningQuestionsEnabled()) {
    List<BurningQuestionItemDTO> burningQuestionItemDtos = scratchieService.getBurningQuestionDtos(scratchie,
	    null, true, true);
    sessionMap.put(ScratchieConstants.ATTR_BURNING_QUESTION_ITEM_DTOS, burningQuestionItemDtos);
}

// Create reflectList if reflection is enabled.
if (scratchie.isReflectOnActivity()) {
    List<ReflectDTO> reflections = scratchieService.getReflectionList(contentId);
    sessionMap.put(ScratchieConstants.ATTR_REFLECTIONS, reflections);
}

Map<String, Object> modelAttributes = scratchieService.prepareStudentChoicesData(scratchie);
model.addAllAttributes(modelAttributes);

return "pages/monitoring/monitoring";
   }