分享java帶來的快樂

          我喜歡java新東西

          導航

          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          統計

          常用鏈接

          留言簿(8)

          文章分類

          文章檔案

          相冊

          收藏夾

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主題:JSP頁面EL表達式無效的問題

          以前用WSAD wizard做的,都可以在JSP頁面中解析到EL表達式,當然前提是JSP2.0的情況下。
          今天遇到了一個莫名其妙的問題。剛下載Eclipse3.3+MyEclipse6.0體驗的過程中,遇上了解析不到EL表達式的問題。經過好幾個小時的琢磨終于發現了,給大家share一下:
          問題就出在建Web Project的時候web.xml聲明上。
          web.xml聲明部分一般分為如下版本的xsd,
          web-app_2_2.xsd
          web-app_2_3.xsd
          web-app_2_4.xsd
          web-app_2_5.xsd

          更詳細的列出各版本web.xml聲明部分吧,如下:
          web-app_2_2.xsd
          Java代碼 復制代碼
          1. <?xml version="1.0" encoding="UTF-8"?>   
          2. <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/dtd/web-app_2_2.dtd">  

          web-app_2_3.xsd
          Java代碼 復制代碼
          1. <?xml version="1.0" encoding="UTF-8"?>   
          2. <!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_2_4.xsd
          Java代碼 復制代碼
          1. <?xml version="1.0" encoding="UTF-8"?>   
          2. <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">  

          web-app_2_5.xsd
          Java代碼 復制代碼
          1. <?xml version="1.0" encoding="UTF-8"?>   
          2. <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee   http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">  


          確定web.xml里的xsd版本之后一定要在JSP的聲明(<%@page %>)部分加一行,如下:
          <%@ page isELIgnored="false" %>
          這樣設為false才能解析EL表達式。
          經過各版本的test之后....
          注意!! 其中servlets 2.4(我沒記錯的話JSP 2.0出來之后的第一個版本),這個版本的isELIgnored默認設置為false。所以使用web.xml里用web-app_2_4.xsd聲明的時候在JSP頁面不用特意聲明。

          下面是官方Documention中isELIgnored Attribute的詳解:
          The isELIgnored Attribute
          • Format
          – <%@ page isELIgnored="false" %>
          – <%@ page isELIgnored="true" %>
          Purpose
          – To control whether the JSP 2.0 Expression Language
          (EL) is ignored (true) or evaluated normally (false).
          • Notes
          – If your web.xml specifies servlets 2.3 (corresponding to
          JSP 1.2) or earlier, the default is true
          • But it is still legal to change the default—you are permitted
          to use this attribute in a JSP-2.0-compliant server
          regardless of the web.xml version.
          – If your web.xml specifies servlets 2.4 (corresponding to
          JSP 2.0) or earlier, the default is false

          posted on 2008-12-27 23:22 強強 閱讀(216) 評論(0)  編輯  收藏 所屬分類: web技巧

          主站蜘蛛池模板: 安泽县| 迭部县| 安丘市| 松江区| 无锡市| 寿宁县| 泸西县| 蒲江县| 报价| 安塞县| 宁城县| 定陶县| 广东省| 宁晋县| 平遥县| 锡林郭勒盟| 通州区| 华安县| 潜山县| 尚志市| 嘉兴市| 宿州市| 通州区| 乌海市| 应用必备| 基隆市| 仪陇县| 建湖县| 泽库县| 玉林市| 南京市| 米脂县| 巢湖市| 若尔盖县| 宁化县| 普格县| 萨嘎县| 双峰县| 礼泉县| 松桃| 新河县|