本文整理汇总了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";
}
示例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;
}
示例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;
}
示例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";
}
示例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";
}
示例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";
}
示例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";
}
示例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";
}
示例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";
}
示例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);
}
示例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";
}
示例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";
}
示例13: showFaq
import org.springframework.ui.Model; //导入方法依赖的package包/类
@SuppressWarnings("SameReturnValue")
@RequestMapping
public String showFaq(Model model){
model.addAttribute("LXG - Faq","title");
return "faq";
}
示例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";
}
示例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";
}