当前位置:网站首页>Redirection setting parameters -redirectattributes
Redirection setting parameters -redirectattributes
2022-06-13 02:22:00 【liangjiayy】
Basic use :
@RequestMapping(value = "/accounts", method = RequestMethod.POST)
public String handle(Account account, BindingResult result, RedirectAttributes redirectAttrs) {
if (result.hasErrors()) {
return "accounts/new";
}
// Redirect settings properties
redirectAttrs.addAttribute("id", account.getId()).addFlashAttribute("message", "Account created!");
return "redirect:/accounts/{id}";
}
There are two ways :( In general use addFlashAttribute, Another kind of data is in the address bar , User visible , unsafe )
addAttribute: Reset back in url Put in the parameters ; Essentially, the request parameters are constructed based on your attributes , Then use the request parameters to redirect to the desired page , namely :key1=val1&key2=val2…
Use :// Do not convert to json, Report errors :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: Put it in session in , It will be deleted after the first use
UseMap<String,String> val=new HashMap<>(); ... redirectAttributes.addFlashAttribute("key", val);
边栏推荐
- [keras] data of 3D u-net source code analysis py
- ROS learning-8 pit for custom action programming
- Huawei equipment is configured with CE dual attribution
- Thinking back from the eight queens' question
- Hstack, vstack and dstack in numpy
- Several articles on norms
- Introduction to arm Cortex-M learning
- How to solve the problem of obtaining the time through new date() and writing out the difference of 8 hours between the database and the current time [valid through personal test]
- Leetcode daily question - 890 Find and replace mode
- STM32F103 IIC OLED program migration complete engineering code
猜你喜欢
![[work notes] the problem of high leakage current in standby mode of dw7888 motor driver chip](/img/d1/c4776e3db1b7560331fa569c40831a.jpg)
[work notes] the problem of high leakage current in standby mode of dw7888 motor driver chip

Sensorless / inductive manufacturing of brushless motor drive board based on stm32

Bai ruikai Electronic sprint Scientific Innovation Board: proposed to raise 360 million Funds, Mr. And Mrs. Wang binhua as the main Shareholder

Paper reading - joint beat and downbeat tracking with recurrent neural networks

Barrykay electronics rushes to the scientific innovation board: it is planned to raise 360million yuan. Mr. and Mrs. Wang Binhua are the major shareholders

Basic principle of bilateral filtering

Classification and summary of system registers in aarch64 architecture of armv8/arnv9

Hstack, vstack and dstack in numpy

Port mapping between two computers on different LANs (anydesk)

ROS learning -5 how function packs with the same name work (workspace coverage)
随机推荐
Understand speech denoising
C language complex type description
Anti crawling strategy (IP proxy, setting random sleep time, bilbili video information crawling, obtaining real URLs, processing special characters, processing timestamp, and multithreading)
传感器:SHT30温湿度传感器检测环境温湿度实验(底部附代码)
Mean Value Coordinates
Hstack, vstack and dstack in numpy
Chapter7-13_ Dialogue State Tracking (as Question Answering)
在IDEA使用C3P0连接池连接SQL数据库后却不能显示数据库内容
Termux SSH first shell start
【Unity】打包WebGL項目遇到的問題及解决記錄
Easydl related documents and codes
Yovo3 and yovo3 tiny structure diagram
Application and examples of C language structure
Linear, integer, nonlinear, dynamic programming
Barrykay electronics rushes to the scientific innovation board: it is planned to raise 360million yuan. Mr. and Mrs. Wang Binhua are the major shareholders
Mbedtls migration experience
Fast Color Segementation
[analysis notes] source code analysis of siliconlabs efr32bg22 Bluetooth mesh sensorclient
Automatic differential reference
Swiper horizontal rotation grid