当前位置:网站首页>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);
边栏推荐
- 1000粉丝啦~
- What are the differences in cache/tlb?
- 柏瑞凱電子沖刺科創板:擬募資3.6億 汪斌華夫婦為大股東
- Leetcode 473. 火柴拼正方形 [暴力+剪枝]
- GMM Gaussian mixture model
- About the fact that I gave up the course of "Guyue private room course ROS manipulator development from introduction to actual combat" halfway
- 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]
- STM32 external interrupt Usage Summary
- (novice to) detailed tutorial on machine / in-depth learning with colab from scratch
- Leetcode 450. 删除二叉搜索树中的节点 [二叉搜索树]
猜你喜欢
![[work with notes] NDK compiles the open source library ffmpeg](/img/24/ed33e12a07e001fc708e0c023e479c.jpg)
[work with notes] NDK compiles the open source library ffmpeg

Paper reading - beat tracking by dynamic programming

Port mapping between two computers on different LANs (anydesk)

Chapter7-13_ Dialogue State Tracking (as Question Answering)

Stm32 mpu6050 servo pan tilt support follow

Deep learning the principle of armv8/armv9 cache

Application circuit and understanding of BAT54C as power supply protection

4.11 introduction to firmware image package

Is space time attention all you need for video understanding?

Area of basic exercise circle ※
随机推荐
Review the history of various versions of ITIL, and find the key points for the development of enterprise operation and maintenance
STM32 sensorless brushless motor drive
json,xml,txt
Sensor: MQ-5 gas module measures the gas value (code attached at the bottom)
Termux SSH first shell start
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%
Linear, integer, nonlinear, dynamic programming
Chapter7-13_ Dialogue State Tracking (as Question Answering)
Graph theory, tree based concept
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]
Chapter7-10_ Deep Learning for Question Answering (1/2)
哈夫曼树及其应用
Thinking back from the eight queens' question
Leetcode 450. 删除二叉搜索树中的节点 [二叉搜索树]
Easydl related documents and codes
[pytorch]fixmatch code explanation - data loading
Area of basic exercise circle ※
[keras] generator for 3D u-net source code analysis py
Basic exercise of test questions Yanghui triangle (two-dimensional array and shallow copy)
Barrykay electronics rushes to the scientific innovation board: it is planned to raise 360million yuan. Mr. and Mrs. Wang Binhua are the major shareholders