This is an example where js cannot use el expressions, but the same is true for html. If it is not a jsp file, it cannot be used.
#html cannot use jstl tags.
el expression (when using el expression to directly obtain the value, for example, ${msg}, there is no need to provide the set get method for msg; but when obtaining the attribute value of the object,
For example, user.name, the set get method must be provided for the name attribute) is a jsp-related concept, which is executed on the server. After the server is executed, it is passed to the client browser. js is executed on the client. When executed by the browser, el has been executed before js.
EL, JSTL and other tags are executed on the server and then sent to the client through the network. The browser client will execute the js script after receiving it. In other words, when the el expression takes effect, the js code is all text. When the js takes effect, the el expression is gone. You can view the source code in the browser and you will find the el tag ${} All gone, converted into specific values.
jsp, js, and html are not on the same plane. They cannot be executed at the same time at the same time. They have no intersection. So the word "use" in the title is in double quotes. It is not that js actually uses the el expression, but uses the final converted value of the el expression.
Similarly, "using" java code in js is the same as using el expressions: JSP is first compiled to compile the java code to form a complete page and then sends it to the client. js is only executed on the client side. When js is executed, js can no longer see the java code.
In js and html filesYou cannot directly use el expressions and java codes (the browser cannot recognize el and other tags in jsp: the result returned to the client is JSP The result of file execution, does not contain any JSP syntax). However, el expressions, java code, js scripts, jstl tags, etc. can all be used in jsp files. Therefore, if you want to use the value of el expression or the value of java code in js code, you can use a bridge like jsp file. Achieve their goals!
js is written in a jsp file. Tags that can be used by jsp (el expressions, jstl tags, java codes, etc.) can be "used" by js; if js is written in a separate file, no tags can be "used" ”, all to no avail. However, it is generally not recommended to use messy jsp tags in js.
The above is the detailed content of Can html use jstl tags?. For more information, please follow other related articles on the PHP Chinese website!