今天在IDEA创建web项目之后发现无法使用EL和JSTL,

一、如果JSP中无法自动提示EL表达式,比如${pageContext.request.contextPath},可在pom.xml的<dependencies>标签中插入以下代码

<dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>jsp-api</artifactId>
      <version>2.0</version>
      <scope>provided</scope>
</dependency>

  

 

下面是EL和JSTL的坐标,不用pom.xml中设置,由上面的依赖传递:

    <!--EL和JSTL-->
    <dependency>
      <groupId>taglibs</groupId>
      <artifactId>standard</artifactId>
      <version>1.1.2</version>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>jstl</artifactId>
      <version>1.2</version>
    </dependency>

 

 

二、如果无法使用EL表达式 
方法1:更改web.xml的web-app标签中的命名空间,可改成如下

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    id="WebApp_ID" version="3.0">

</web-app>

 

 

 

 

 

 

 

方法2:在jsp页面开头添加<%@ page isELIgnored="false"%>

 

相关文章:

  • 2021-05-19
  • 2021-06-22
  • 2022-12-23
  • 2021-08-18
  • 2021-04-02
  • 2022-01-19
  • 2021-11-21
  • 2022-12-23
猜你喜欢
  • 2021-04-03
  • 2021-10-08
  • 2021-09-24
  • 2021-07-27
  • 2021-05-31
  • 2021-05-25
  • 2021-09-14
相关资源
相似解决方案