Tips for passing values on HTML5 + js pages to the Java Background: html5js
Tips for page value passing
For a web project we usually do, there are several steps on an HTML page, step_num ①, step_num ②, step_num ③. step_num ① is displayed first, and step_num ② is displayed according to the jump condition, step_num ① hide, jump to step_num ③, step_num ①, step_num ② hide, step_num ③ show.
Idea: (js sets global variables, where to add an input tag, assigns the value to an input, and then hides the input ).
First, let's talk about the structure of the webpage. Go to the xxx.html page and send an ajax. postForm request through js to request an action. action calls handler. Each function requests an action.
Two days ago, we made such a page. When we passed the value, we encountered a problem that made the human brain hurt. We need to display and undisplayed values in step_num ①, passed To step_num ③ the corresponding background Java code. I was also very drunk. I tried several methods and it was not easy to use. Finally, I used a small trick.
Set a global variable in js, such as var groupID = "";, and then assign the GroupID passed from step_num ① from the background action to groupID, how can I transmit the data to the corresponding Java backend of page 3?
Enter the following statement in the HTML code corresponding to step_num ③: <input id = "chuanzhi" name = "chuanzhi" type = "hidden"/>
Then, in the corresponding js Code, set $ ("# chuanzhi"). val (groupID );
In this way, you can get the groupID you want through request. getParameter ("chuanzhi") in the corresponding Java background of step_num ③.