今天用Spring Security时遇到了EL表达式不被解析,而是原封不动地显示在页面上的问题。仔细搜之,得出原因如下:
EL表达式只在servlet2.4规范中被支持,而我的web.xml中声明使用的servlet规范为2.3。
有2种解决办法:
1、将web.xml改为servlet2.4规范:
代码
<?
xml version="1.0" encoding="UTF-8"
?>
< web-app xmlns ="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance"
version ="2.4"
xsi:schemaLocation ="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
</ web-app >
< web-app xmlns ="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance"
version ="2.4"
xsi:schemaLocation ="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
</ web-app >
2、在jsp文件开头加上:
<%
@ page isELIgnored
=
"
false
"
%>