溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

如何解決el表達式與jstl標簽不能用的問題

發布時間:2020-08-11 15:39:15 來源:億速云 閱讀:270 作者:小新 欄目:編程語言

小編給大家分享一下如何解決el表達式與jstl標簽不能用的問題,希望大家閱讀完這篇文章后大所收獲,下面讓我們一起去探討吧!

開發過程中有時會遇到這樣的問題,el表達式與jstl標簽不能用。這對懶人可真是災難,用不了不僅要多寫許多代碼,頁面也會看著特別臃腫,文中有些方法希望可以幫到你。

如何解決el表達式與jstl標簽不能用的問題

如下圖所示:

如何解決el表達式與jstl標簽不能用的問題首先我們要確保所需要的maven依賴都要添加

<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文件設置

<%@ page isELIgnored="false" %>

或者在web.xml設置

<el-ignored>true</el-ignored>

它應該是false默認,但如果你使用的servlet版本低于2.4,則默認為true,所以在這種情況下,你需要將其設置為false在web.xml:

<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為:

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

修改完畢后的效果:

如何解決el表達式與jstl標簽不能用的問題

看完了這篇文章,相信你對如何解決el表達式與jstl標簽不能用的問題有了一定的了解,想了解更多相關知識,歡迎關注億速云行業資訊頻道,感謝各位的閱讀!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女