Can javascript use el expressions
This article introduces the relevant knowledge of "whether javascript can use el expression". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Javascript can use el expressions. Method: 1, JavaScript code in the JSP page, directly use EL expression, syntax is "$(function () {new... (" ${param.alert} ");});"; 2, use the form of pre-defined JS variable.
The operating environment of this tutorial: windows10 system, javascript1.8.5 version, Dell G3 computer.
Can javascript use el expressions?
EL (Expression Language) is designed to make JSP easier to write. The expression language, inspired by the ECMAScript and XPath expression languages, provides a way to simplify expressions in JSP, making the Jsp code even easier.
The method of using el expressions in JavaScript.
1. The JavaScript code is in the JSP page, which can be directly used by EL expressions. Such as:
(function () {new BacklogOverview ("${param.alert}");})
2. JS code is a separate .js file, which is introduced into JSP. This can be solved by defining JS variables in advance, such as:
Var contextPath = "${contextPath}"
EL syntax
Accessing model objects in JSP is expressed through the syntax of EL expressions. All EL expressions are formatted as "${}". For example, ${userinfo} means to get the value of the variable userinfo.
When the variables in the EL expression are not given a range, they default to look in the page range, and then look in the request, session, and application ranges. You can also use a range as a prefix to indicate which range variables belong to, for example: ${pageScope. Userinfo} means to access the userinfo variable in the scope of page.
This is the end of the content of "whether javascript can use el expressions". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!