Why is the tag "$ {}" in jsp output as a string

I want to import a js file into my jsp this way

<script type="text/javascript" src="${pageContext.request.contextPath}/js/layout/jquery-ui.js"></script> 

but when I look at the expanded page, I found that part of ${pageContext.request.contextPath} displayed in browsers as a string, the code above tries to find the js file in the folder ${pageContext.request.contextPath}/js/layout/ instead of XXX/js/layout/

My evolving environment is "Myeclipse10.5 + Tomcat7.0 + JDK7.0"

+4
source share
2 answers

Make sure your JSP is not configured to ignore EL with the page directive

 <%@ page ... isELIgnored="true" %> 

Or, make sure your web.xml not disabled EL for all JSPs using

 <jsp-config> ... <el-ignored>true</el-ignored> ... </jsp-config> 


EDIT :

Also, make sure your version of web.xml <web-app> 2.4 or higher. Add the following to your web.xml as a workaround (if nothing works):

 <jsp-config> <jsp-property-group> <url-pattern>*.jsp</url-pattern> <el-ignored>false</el-ignored> </jsp-property-group> </jsp-config> 
0
source

This is part of Java EL (Expression Language)

See http://docs.oracle.com/javaee/1.4/tutorial/doc/JSPIntro7.html for how it works.

0
source

Source: https://habr.com/ru/post/1498896/


All Articles