本文整理匯總了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";
}