In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is about how Java parses the front-end data through two or three methods. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article. Let's take a look at it.
I. Preface
Last time we talked about three ways to accept data at the back end, so it's natural to understand and learn data today.
In the front-end display, the front-end display is also very important, which shows what we buy on platforms like shopping.
The principle is the front-end display.
Second, the body part
Many people see that this title may have some "two or three methods". Don't worry, take your time, and the answer will be at ease.
Model method:
Open the article we wrote earlier, under the Demo class, as shown in the figure, this is the first method of my back-end data acceptance
The front-end data acceptance only needs to add Model model in the second public String parenthesis, where the second model can
It's any name. For the sake of image, we call it model.
Then write it down as shown in the figure
Among them, the one under the "" is the name to be displayed at the front end, which can be taken at will without "", it is under the back end, and this is to be defined.
It's the same. Should be written after the defined variable (after String)
The second is to fill in the figure outside the jsp:
Click run and search localhost:8080 on Baidu to view it.
The second backend data is accepted as shown in the figure:
The method is the same, as shown under the second public String:
It's still the same in jsp, so here we run it directly:
Show success after submission
The third way is to accept the back-end data:
After running:
At this point, is it easy to end the use of Model under three kinds of backend data acceptance?
Map method:
Map is more troublesome than Model.
The first is shown in the picture:
Need to be under the Demo class:
Add this sentence under @ Controller:
SessionAttributes (value= {"zh", "mm"}, types= {String.class, String.class})
As shown in the figure:
Then add Map map under the second public and then add the figure in parentheses:
In order to compare with the fact that I didn't delete the Model I used last time, I distinguished whether I used the "" front-end display or not.
At this point, we are under jsp:
You can write this directly, but the following is recommended, which is complicated but has a clear meaning.
After running directly:
The one above is Model's and the bottom is Map's.
In the second way:
In @ Controller, you still need to add:
SessionAttributes (value= {"zh", "mm"}, types= {String.class, String.class})
Because the content under jsp has been done before, after running:
However, under the third ModelAttribute, Map does not support:
After running:
So @ ModelAttribute does not support the Map method.
This is how Java parses the front-end data through two or three methods. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.