本文整理匯總了Java中org.springframework.web.servlet.mvc.support.RedirectAttributes.addAttribute方法的典型用法代碼示例。如果您正苦於以下問題:Java RedirectAttributes.addAttribute方法的具體用法?Java RedirectAttributes.addAttribute怎麽用?Java RedirectAttributes.addAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.web.servlet.mvc.support.RedirectAttributes
的用法示例。
在下文中一共展示了RedirectAttributes.addAttribute方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateUser
import org.springframework.web.servlet.mvc.support.RedirectAttributes; //導入方法依賴的package包/類
@RequestMapping(value = "/users/update/{userId}", method = RequestMethod.POST)
public String updateUser(@Valid UserDTO userDTO, BindingResult result,
RedirectAttributes attributes, Model model) {
if (result.hasErrors()) {
model.addAttribute("authorities", userService.getRoles());
return ADMIN_USERFORM_VIEW;
} else {
userDTO.setUpdateChildren(true);
userService.update(userDTO);
attributes.addAttribute(PARAMETER_USER_ID, userDTO.getUserId());
webUI.addFeedbackMessage(attributes, FEEDBACK_MESSAGE_KEY_USER_UPDATED,
userDTO.getFirstName() + " " + userDTO.getLastName());
return "redirect:/admin/users";
}
}
示例2: deleteCat
import org.springframework.web.servlet.mvc.support.RedirectAttributes; //導入方法依賴的package包/類
@RequestMapping(value = "/cats/{id}/delete", method = RequestMethod.POST)
public String deleteCat(@PathVariable("id") long id, final RedirectAttributes redirectAttributes) {
logger.debug("deleteCat() id: {}", id);
if (catService.existsById(id)) {
catService.delete(catService.findById(id).get());
redirectAttributes.addFlashAttribute("css", "success");
redirectAttributes.addFlashAttribute("msg", "Cat is deleted!");
} else {
redirectAttributes.addAttribute("css", "danger");
redirectAttributes.addAttribute("msg", "Cat not found.");
}
return "redirect:/cats";
}
示例3: sendRedirection
import org.springframework.web.servlet.mvc.support.RedirectAttributes; //導入方法依賴的package包/類
@RequestMapping(value="/jump_page.html", method=RequestMethod.POST)
public RedirectView sendRedirection(RedirectAttributes atts, @RequestParam("username") String username,
@RequestParam("password") String password){
atts.addFlashAttribute("username", username);
atts.addFlashAttribute("password", password);
atts.addAttribute("request", "loginForm");
return new RedirectView("/redirectviewOld.html",true);
}
示例4: authorize
import org.springframework.web.servlet.mvc.support.RedirectAttributes; //導入方法依賴的package包/類
@RequestMapping(value = "/fake/authorize", method = RequestMethod.POST)
public String authorize(
@RequestParam("state") String state,
@RequestParam("redirectUri") String redirectUri,
@RequestParam("username") String username,
@RequestParam("password") String password,
RedirectAttributes redirectAttributes) {
logger.debug("Fake TMC controller received login credentials");
//TODO: Move the test users to a centralized place from here and DataImporter
Map<String, String> creds = new HashMap<>();
creds.put("user", "password");
creds.put("admin", "password");
creds.put("impluser", "password");
if (!creds.containsKey(username) || !creds.get(username).equals(password)) {
logger.debug("Access denied");
redirectAttributes.addAttribute("error", "access_denied");
} else {
logger.debug("Access granted");
redirectAttributes.addAttribute("code", username);
}
redirectAttributes.addAttribute("state", state);
String redirectPath = redirectUri.replace("http://localhots:8080", "");
logger.debug("Redirecting to {}", redirectPath);
return "redirect:" + redirectPath;
}
示例5: mailprove
import org.springframework.web.servlet.mvc.support.RedirectAttributes; //導入方法依賴的package包/類
/**
* 驗證郵箱
* @param checkcode 驗證碼
* @return
*/
@RequestMapping(value = "/mailprove",method = RequestMethod.GET)
public String mailprove(String checkcode,RedirectAttributes model){
model.addAttribute("registerType", "email");
//參數檢測
if(checkcode==null||"".equals(checkcode)){
model.addAttribute("code", 500);
model.addAttribute("msg", "驗證碼不能為空!");
return "redirect:/system/register/success";
}
//獲取校驗參數
byte[] bytes = SecurityUtil.decryptBASE64(checkcode);
Map<String,Object> paramMap = ( Map<String,Object>) JavaSerializeUtil.deserialize(bytes);
String email = (String) paramMap.get("email");
Date date = (Date) paramMap.get("date");
model.addAttribute("contact", email);
if(email==null||date==null||DateUtils.compareDate(new Date(),date, Calendar.HOUR)>48){
model.addAttribute("code", 500);
model.addAttribute("msg", "注冊鏈接已過期,請重新注冊!");
return "redirect:/system/register/success";
}
//根據郵箱賬號查找用戶
List<SysUser> sysUsers = userService.querySysUserByCondition(null, null, email, null, null);
if(sysUsers==null||sysUsers.size()!=1){
model.addAttribute("code", 500);
model.addAttribute("msg", "郵箱激活出現異常,請聯係管理員!");
return "redirect:/system/register/success";
}
//檢測用戶是否已經激活
SysUser sysUser = sysUsers.get(0);
if(SysUser.USER_STATUS_ACTIVE.equals(sysUser.getUserStatus())){
model.addAttribute("code", 500);
model.addAttribute("msg", "郵箱已經激活,請登錄!");
return "redirect:/system/register/success";
}
//激活用戶
SysUser registerUser=new SysUser();
registerUser.setUserId(sysUser.getUserId());
registerUser.setUserStatus(SysUser.USER_STATUS_ACTIVE);
registerUser.setEmailActive(SysUser.USER_STATUS_ACTIVE);
userService.updateById(registerUser);
model.addAttribute("code", 200);
model.addAttribute("msg", "郵箱激活成功!");
return "redirect:/system/register/success";
}
示例6: modalAutoclose
import org.springframework.web.servlet.mvc.support.RedirectAttributes; //導入方法依賴的package包/類
/**
* Set the automatic closing time for the notification - no close button is shown
* @param milliseconds
* @param redirectAttributes
* @deprecated Use YadaNotify instead
*/
@Deprecated
public void modalAutoclose(long milliseconds, RedirectAttributes redirectAttributes) {
redirectAttributes.addAttribute(KEY_NOTIFICATION_AUTOCLOSE, milliseconds);
}
示例7: modalReloadOnClose
import org.springframework.web.servlet.mvc.support.RedirectAttributes; //導入方法依賴的package包/類
/**
* Set the page to reload when the modal is closed
* @param redirectAttributes
* @deprecated Use YadaNotify instead
*/
@Deprecated
public void modalReloadOnClose(RedirectAttributes redirectAttributes) {
redirectAttributes.addAttribute(KEY_NOTIFICATION_RELOADONCLOSE, KEY_NOTIFICATION_RELOADONCLOSE);
}