关于在JSP页面识别不了EL表达式的情况

今天在JSP页面接收Controller返回的数据user_nickname,使用EL表达式显示数据发现在页面输出的始终是字符串${user_nickname}

经过查阅资料,问题在于使用的web.xm版本约束为2.3时,JSP头部未设置isELIgnored属性为false

原头部

1 <%@ page contentType="text/html;charset=UTF-8" language="java"%>

修改后的头部

1 <%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>

经过设置isELIgnored属性为false即可输出Controller传来的user_nickname数据,否则会将${user_nickname}当作字符串而不是EL表达式处理

另外,还可以通过修改web.xml版本约束的方式

原版本约束: web-app 2.3

1 <!--版本约束-->
2 <!DOCTYPE web-app PUBLIC
3  "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
4  "http://java.sun.com/dtd/web-app_2_3.dtd" >
5 <!--代码段-->
6 <web-app>
7     ******
8 </web-app>

修改版本约束:web-app 3.1

1 <!--版本约束-->
2 <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
3    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
5    version="3.1"> 
6 <!--代码段-->
7     ******
8 </web-app> 
posted @ 2020-07-11 14:53  HuskySir  阅读(341)  评论(0编辑  收藏  举报