There are two situations: 1. The JS code is in the JSP page, which can directly use ELexpression. 2. The JS code is a separate .js file, which is introduced into the JSP. At this time, it can be solved by defining JS variables in advance
1. The JS code is in the JSP page , this can directly use EL expressions. For example:
[html] view plain copy <script type="text/javascript"> $(function () { new BacklogOverview("${param.alert}"); }); </script>
2. The JS code is a separate .js file, which is introduced into the JSP. At this time, it can be solved by defining JS variables in advance, such as :
[html] view plain copy <c:set var="contextPath" value="${pageContext.request.contextPath}" scope="application"/> <script> <%--JS gloable varilible--%> var contextPath = "${contextPath}"; </script>
Define the JS variable contextPath on the JSP page.
So that the contextPath variable can be used in the JS files introduced later.
[html] view plain copy //Image setting config.filebrowserImageUploadUrl = contextPath + "/ckeditor/upload.htm";
The above is I compiled the JS using EL expressions for everyone. I hope it will be helpful to everyone in the future.
Related articles:
Key points analysis and answers to rewriting and polymorphism
How to rewrite the padleft method in js
What are the inheritance methods in js
The above is the detailed content of Detailed introduction to using EL expressions in JS. For more information, please follow other related articles on the PHP Chinese website!