Mutual transmission of JS and Java Variables
In JSP, JS variables are often assigned to Java variables, or Java variables are assigned to JS variables. Here we will summarize the general processing methods as follows:
It is easy to pass the Java variable to JS. var A = "<% = javaparam %>"; note that you must add the quotation marks;
JS variables are a little complex for Java. Generally,
And then assign the JS variable value to it in the script:
VaR jsparamvalue = 'aaa ';
Form1.jsparam. value = jsparamvalue;
Then you can request. getprameter ("jsprama"); To Get The JS variable value.
Supplement: Ajax is actually a real-time technology that transfers JS variables to the server without refreshing the page.
Summary:
You cannot assign values to Java variables on the page using JS variables;
Instead, you can use VaR jsparam = "<% = javaparam %>" to assign the Java variable to the JS variable.