当前位置: 首页>>代码示例>>Java>>正文


Java Model.addAttribute方法代码示例

本文整理汇总了Java中org.springframework.ui.Model.addAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java Model.addAttribute方法的具体用法?Java Model.addAttribute怎么用?Java Model.addAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.ui.Model的用法示例。


在下文中一共展示了Model.addAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: saveOrUpdate

import org.springframework.ui.Model; //导入方法依赖的package包/类
@RequestMapping(value = "/save.d", produces = "application/json;charset=UTF-8")
public String saveOrUpdate(MultipartHttpServletRequest multipartReq, MoFeatured moFeatured, Model model) {
    try {
        if (moFeatured.getPicType() == 3) {
            String bigPics = StringUtils.defaultIfEmpty(moFeatured.getBigPics(), "").replace(",,", "");
            moFeatured.setBigPics(StringUtils.stripEnd(StringUtils.stripStart(bigPics, ","), ","));
        } else {
            String pics = StringUtils.defaultIfEmpty(moFeatured.getPics(), "").replace(",,", "");
            moFeatured.setPics(StringUtils.stripEnd(StringUtils.stripStart(pics, ","), ","));
        }
        moFeaturedService.saveOrUpdate(multipartReq, moFeatured);
        model.addAttribute("rstCode", 0);
    } catch (Exception e) {
        model.addAttribute("rstCode", 1);
    }
    return "/moFeatured/save";
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:18,代码来源:MoFeaturedController.java

示例2: exception

import org.springframework.ui.Model; //导入方法依赖的package包/类
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!   ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append(" root cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:21,代码来源:ErrorController.java

示例3: play

import org.springframework.ui.Model; //导入方法依赖的package包/类
@RequestMapping(value = "/photos", method = GET)
public String play(Model model) {
    model.addAttribute("parentId", SharedUtils.randomNegativeId());
    model.addAttribute("fileuploading", fmService.getFileUploadingScript());
    model.addAttribute("fileuploaded", fmService.getFileUploadedScript());
    return POSTS_PLAY_VIEW;
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:8,代码来源:PostsUploadController.java

示例4: input

import org.springframework.ui.Model; //导入方法依赖的package包/类
@RequestMapping("pim-plan-input")
public String input(@RequestParam(value = "id", required = false) Long id,
        Model model) {
    if (id != null) {
        PimPlan pimPlan = pimPlanManager.get(id);
        model.addAttribute("model", pimPlan);
    }

    return "pim/pim-plan-input";
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:11,代码来源:PimPlanController.java

示例5: list

import org.springframework.ui.Model; //导入方法依赖的package包/类
@RequestMapping("sale-info-list")
public String list(@ModelAttribute Page page,
        @RequestParam Map<String, Object> parameterMap, Model model) {
    String tenantId = tenantHolder.getTenantId();
    List<PropertyFilter> propertyFilters = PropertyFilter
            .buildFromMap(parameterMap);
    propertyFilters.add(new PropertyFilter("EQS_tenantId", tenantId));
    page = saleInfoManager.pagedQuery(page, propertyFilters);

    model.addAttribute("page", page);

    return "sale/sale-info-list";
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:14,代码来源:SaleInfoController.java

示例6: list

import org.springframework.ui.Model; //导入方法依赖的package包/类
/**
 * 当前输入模型列表
 */
@RequestMapping("list")
public String list(HttpServletRequest request, Model model){
	AliyunLog.addActionLog(getSiteId(), "进入CMS模式下自定义输入模型列表");
	
	model.addAttribute("list", inputModelService.getInputModelListForSession());
	return "inputModel/list";
}
 
开发者ID:xnx3,项目名称:wangmarket,代码行数:11,代码来源:InputModelController.java

示例7: update

import org.springframework.ui.Model; //导入方法依赖的package包/类
@RequestMapping(value = "/update", method = RequestMethod.GET)
public String update(Model model) {
    Iterable<User> users = usersService.findAll();
    Iterable<UserRole> roles = userRolesService.findAll();
    Iterable<Address> address = addressService.findAll();

    model.addAttribute("address", address);
    model.addAttribute("users", users);
    model.addAttribute("roles", roles);
    return "administratorSite/usersManager/update";
}
 
开发者ID:xSzymo,项目名称:Spring-web-shop-project,代码行数:12,代码来源:UpdateUsers.java

示例8: login

import org.springframework.ui.Model; //导入方法依赖的package包/类
@RequestMapping(value = "/login", method = RequestMethod.POST)
public String login(HttpServletRequest request, HttpServletResponse response, Model model) {
    HttpRequestResponseHolder holder = new HttpRequestResponseHolder(request, response);
    httpSessionSecurityContextRepository.loadContext(holder);

    try {
        // 使用提供的证书认证用户
        List<GrantedAuthority> authorities = AuthorityUtils.createAuthorityList("ROLE_USER", "ROLE_ADMIN");
        Authentication auth = new UsernamePasswordAuthenticationToken(request.getParameter("username"), request.getParameter("password"), authorities);
        SecurityContextHolder.getContext().setAuthentication(authenticationManager.authenticate(auth));

        // 认证用户
        if(!auth.isAuthenticated())
            throw new CredentialException("用户不能够被认证");
    } catch (Exception ex) {
        // 用户不能够被认证,重定向回登录页
        logger.info(ex);
        return "login";
    }

    // 从会话得到默认保存的请求
    DefaultSavedRequest defaultSavedRequest = (DefaultSavedRequest) request.getSession().getAttribute("SPRING_SECURITY_SAVED_REQUEST");
    // 为令牌请求生成认证参数Map
    Map<String, String> authParams = getAuthParameters(defaultSavedRequest);
    AuthorizationRequest authRequest = new DefaultOAuth2RequestFactory(clientDetailsService).createAuthorizationRequest(authParams);
    authRequest.setAuthorities(AuthorityUtils.createAuthorityList("ROLE_USER", "ROLE_ADMIN"));
    model.addAttribute("authorizationRequest", authRequest);

    httpSessionSecurityContextRepository.saveContext(SecurityContextHolder.getContext(), holder.getRequest(), holder.getResponse());
    return "authorize";
}
 
开发者ID:chaokunyang,项目名称:microservices-event-sourcing,代码行数:32,代码来源:LoginController.java

示例9: popupSiteUpdate

import org.springframework.ui.Model; //导入方法依赖的package包/类
/**
 * 弹出框,站点信息修改
 * 网站设置-修改联系信息,如地址、QQ等
 */
@RequestMapping("popupSiteUpdate.do")
public String popupSiteUpdate(Model model){
	AliyunLog.addActionLog(getSiteId(), "弹出弹出框,显示站点信息修改");
	
	model.addAttribute("site", getSite());
	return "site/popup_site";
}
 
开发者ID:xnx3,项目名称:wangmarket,代码行数:12,代码来源:SiteController.java

示例10: references

import org.springframework.ui.Model; //导入方法依赖的package包/类
private void references(Model model){
	List<Integer> deptIds = new ArrayList<>();
	List<Department> depts = departmentServiceImpl.readDepartments().getNow(new ArrayList<>());
	Iterator<Department> iterate = depts.iterator();
	while(iterate.hasNext()){
		deptIds.add(iterate.next().getId());
	}
	model.addAttribute("deptIds", deptIds);
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:10,代码来源:EmployeeController.java

示例11: input

import org.springframework.ui.Model; //导入方法依赖的package包/类
@RequestMapping("vote-info-input")
public String input(@RequestParam(value = "id", required = false) Long id,
        Model model) {
    if (id != null) {
        VoteInfo voteInfo = voteInfoManager.get(id);
        model.addAttribute("model", voteInfo);
    }

    return "vote/vote-info-input";
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:11,代码来源:VoteInfoController.java

示例12: readOne

import org.springframework.ui.Model; //导入方法依赖的package包/类
@RequestMapping(value = "read", method = RequestMethod.POST)
public String readOne(@RequestParam("id") String id, Model model) {
    CouponCode couponCode = couponCodesService.findOne(Long.parseLong(id));

    if (couponCode == null) {
        model.addAttribute("msg", "not found");
        return "administratorSite/couponCodesManager/read";
    }
    model.addAttribute("couponCode", couponCode);
    return "administratorSite/couponCodesManager/read";
}
 
开发者ID:xSzymo,项目名称:Spring-web-shop-project,代码行数:12,代码来源:ReadCouponCodes.java

示例13: showFaq

import org.springframework.ui.Model; //导入方法依赖的package包/类
@SuppressWarnings("SameReturnValue")
@RequestMapping
public String showFaq(Model model){

    model.addAttribute("LXG - Faq","title");
    return "faq";

}
 
开发者ID:Recks11,项目名称:theLXGweb,代码行数:9,代码来源:FaqController.java

示例14: list

import org.springframework.ui.Model; //导入方法依赖的package包/类
@RequestMapping("book-borrow-list")
public String list(@ModelAttribute Page page,
        @RequestParam Map<String, Object> parameterMap, Model model) {
    List<PropertyFilter> propertyFilters = PropertyFilter
            .buildFromMap(parameterMap);
    page = bookBorrowManager.pagedQuery(page, propertyFilters);

    model.addAttribute("page", page);

    return "book/book-borrow-list";
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:12,代码来源:BookBorrowController.java

示例15: index

import org.springframework.ui.Model; //导入方法依赖的package包/类
/**
 * 首页 映射/和/index路径
 *
 * @return
 * @throws Exception
 */
@RequestMapping({ "/", "/index" })
public String index(Model model) throws Exception {
	List<Product> productList = productService.getProductList();
	model.addAttribute("productList", productList);
	return "index";
}
 
开发者ID:honghailiang,项目名称:SpringMango,代码行数:13,代码来源:PageController.java


注:本文中的org.springframework.ui.Model.addAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。