我是靠谱客的博主 顺利跳跳糖,这篇文章主要介绍el表达式与jstl标签不能用解决方法,现在分享给大家,希望可以做个参考。

开发过程中有时会遇到这样的问题,el表达式与jstl标签不能用。这对懒人可真是灾难,用不了不仅要多写许多代码,页面也会看着特别臃肿,本文中有些方法希望可以帮到你。

如下图所示:

csdn-1.png首先我们要确保所需要的maven依赖都要添加

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jsp-api</artifactId> <scope>provided</scope> <version>2.0</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.25</version> </dependency> <dependency> <groupId>jstl</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>taglibs</groupId> <artifactId>standard</artifactId> <version>1.1.2</version> </dependency> </dependencies>
登录后复制

添加相关依赖后,若还是出现上面无法正常显示的情况,可以尝试一下的解决方法:

我认为这不是JSTL的问题,${emp.role}是EL(表达语言),它不起作用。

我们可以在JSP文件设置

复制代码
1
<%@ page isELIgnored="false" %>
登录后复制

或者在web.xml设置

复制代码
1
<el-ignored>true</el-ignored>
登录后复制

它应该是false默认,但如果你使用的servlet版本低于2.4,则默认为true,所以在这种情况下,你需要将其设置为false在web.xml:

复制代码
1
2
3
4
5
6
<jsp-config> <jsp-property-group> <url-pattern>*.jsp</url-pattern> <el-ignored>true</el-ignored> </jsp-property-group> </jsp-config>
登录后复制

您有3.1依赖项版本,但使用的是web.xml文件2.3版本。要使用Servlet 3.1尝试将您更改web.xml为:

复制代码
1
2
3
4
5
6
7
<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"> rest of the TAGs </web-app>
登录后复制

修改完毕后的效果:

csdn-2.png

以上就是el表达式与jstl标签不能用解决方法的详细内容,更多请关注靠谱客其它相关文章!

最后

以上就是顺利跳跳糖最近收集整理的关于el表达式与jstl标签不能用解决方法的全部内容,更多相关el表达式与jstl标签不能用解决方法内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(92)

评论列表共有 0 条评论

立即
投稿
返回
顶部