JSP页面无法识别EL表达式问题解决方案

2025-05-29 0 96

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

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

原头部

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

修改后的头部

<%@ 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

3

4

5

6

7

8
<!--版本约束-->

<!DOCTYPE web-app PUBLIC

"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

"http://java.sun.com/dtd/web-app_2_3.dtd" >

<!--代码段-->

<web-app>

******

</web-app>

修改版本约束:web-app 3.1

?

1

2

3

4

5

6

7

8
<!--版本约束-->

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"

version="3.1">

<!--代码段-->

******

</web-app>

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持快网idc。

原文链接:https://www.cnblogs.com/huskysir/p/13283569.html

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

快网idc优惠网 建站教程 JSP页面无法识别EL表达式问题解决方案 https://www.kuaiidc.com/119672.html

相关文章

发表评论
暂无评论