在jsp中写入如下代码:
<body>
<%request.setAttribute("aaa","www.baidu.com");
%>
<h3>
${aaa}
</h3>
</body>
浏览器解析的时候直接显示${aaa},出现这种情况怎么办?
1、在jsp界面中加入:<%@ page isELIgnored="false" %>
2、将tomcat中的web.xml文件的
<web-app xmlns="
http://java.sun.com/xml/ns/javaee"
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
修改为:
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
3、重新开启tomcat,再将工程发布一下。就能解决这个问题。
ps:此方法是本人在遇到这个问题时,亲自测试通过的。