当前位置:网站首页>重定向设置参数-RedirectAttributes
重定向设置参数-RedirectAttributes
2022-06-13 02:19:00 【liangjiayy】
基本使用:
@RequestMapping(value = "/accounts", method = RequestMethod.POST)
public String handle(Account account, BindingResult result, RedirectAttributes redirectAttrs) {
if (result.hasErrors()) {
return "accounts/new";
}
// 重定向设置属性
redirectAttrs.addAttribute("id", account.getId()).addFlashAttribute("message", "Account created!");
return "redirect:/accounts/{id}";
}
有两种方式:(一般使用addFlashAttribute,另一种数据在地址栏,用户可见,不安全)
addAttribute:重定向后在url后面拼上参数;本质上是根据您的属性构造请求参数,然后使用请求参数重定向到所需的页面,即:key1=val1&key2=val2…
使用:// 不转为json,报错:Cannot convert value of type 'java.util.HashMap' to required type 'java.lang.String' Map<String,String> val=new HashMap<>(); ... redirectAttributes.addAttribute("key", JSONObject.toJSONString(val));addFlashAttribute:放在session中,第一次使用后将删除
使用Map<String,String> val=new HashMap<>(); ... redirectAttributes.addFlashAttribute("key", val);
边栏推荐
- [51nod.3210] binary Statistics (bit operation)
- 记录:如何解决MultipartFile类的transferTo()上传图片报“系统找不到指定的路径“问题【亲测有效】
- 华为设备配置双反射器优化虚拟专用网骨干层
- ROS learning-8 pit for custom action programming
- 蓝牙模块:使用问题集锦
- How to learn to understand Matplotlib instead of simple code reuse
- STM32 IIC protocol controls pca9685 steering gear drive board
- [work notes] the problem of high leakage current in standby mode of dw7888 motor driver chip
- Huawei equipment is configured with dual reflectors to optimize the backbone layer of the virtual private network
- An image is word 16x16 words: transformers for image recognition at scale
猜你喜欢

Bai ruikai Electronic sprint Scientific Innovation Board: proposed to raise 360 million Funds, Mr. And Mrs. Wang binhua as the main Shareholder
![[51nod.3210] binary Statistics (bit operation)](/img/37/aa4a549deebf994b0049d41d49ff12.jpg)
[51nod.3210] binary Statistics (bit operation)

Mac下搭建MySQL环境
![[learning notes] xr872 GUI littlevgl 8.0 migration (file system)](/img/9b/0bf88354e8cfdbcc1ea91311c9a823.jpg)
[learning notes] xr872 GUI littlevgl 8.0 migration (file system)
![[open source] libinimini: a minimalist ini parsing library for single chip computers](/img/99/f2ded6c189bd45ea6c1e9f86fd64c1.jpg)
[open source] libinimini: a minimalist ini parsing library for single chip computers

Thesis reading - autovc: zero shot voice style transfer with only autoencoder loss

ROS learning-8 pit for custom action programming

0- blog notes guide directory (all)

Record: how to solve the problem of "the system cannot find the specified path" in the picture message uploaded by transferto() of multipartfile class [valid through personal test]
![[pytorch]fixmatch code explanation (super detailed)](/img/22/66703bea0f8ee40eceb0687fcb3ad2.jpg)
[pytorch]fixmatch code explanation (super detailed)
随机推荐
Leetcode daily question - 890 Find and replace mode
[work notes] xr872 codec driver migration and application program example (with chip debugging method)
Chapter7-10_ Deep Learning for Question Answering (1/2)
[open source] libinimini: a minimalist ini parsing library for single chip computers
C language conditional compilation routine
Paipai loan parent company Xinye quarterly report diagram: revenue of RMB 2.4 billion, net profit of RMB 530million, a year-on-year decrease of 10%
SWD debugging mode of stm32
Mbedtls migration experience
华为设备配置IP和虚拟专用网混合FRR
Think about the possibility of attacking secure memory through mmu/tlb/cache
Luzhengyao, who has entered the prefabricated vegetable track, still needs to stop being impatient
Basic exercise of test questions Yanghui triangle (two-dimensional array and shallow copy)
[analysis notes] source code analysis of siliconlabs efr32bg22 Bluetooth mesh sensorclient
Microsoft Pinyin opens U / V input mode
Record: how to solve the problem of "the system cannot find the specified path" in the picture message uploaded by transferto() of multipartfile class [valid through personal test]
STM32 steering gear controller
STM32 sensorless brushless motor drive
STM32 IIC protocol controls pca9685 steering gear drive board
柏瑞凱電子沖刺科創板:擬募資3.6億 汪斌華夫婦為大股東
Stm32 mpu6050 servo pan tilt support follow