zoukankan      html  css  js  c++  java
  • jsp页面中的EL表达式不被解析的问题

    原因:问题在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文件也可以。 在jsp页面的<%@ page isELIgnored="false" %>声明中,将isELIgnored属性设为false,EL表达 式才可以正常显示,在2.4版本之前的版本,isELIgnored默认为true,所以只能在JSP页面设置这个属性为false才可以。2.4版本中isELIgnored属性默认为false,因此EL表达式可以直接使用。 

     

    方法:1.JSP页面中<%@ page isELIgnored="false" %>,每个页面都如此,就会很麻烦。 

             2.将web.xml中的声明改为2.4版本,如下: 

    <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee   http://java.sun.com/xml/ns/javaee/web-app_2_4.xsd"> 

     

    下面是官方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 

     

    PS: 我本来的版本是2.5,以前也没出过此类问题,感觉可能是Tomcat的版本不一样造成的问题,在Tomcat中的web.xml中貌似也有可以配置EL可用的定义。这种小问题虽然不起眼,但写程序时感觉还是很容易遇到的,而且只有在亲自写代码时才会碰到,书上是找不到的,所以积少成多,也许这就是经验积累的过程吧! 

     

    PS: 2.5版本的也是默认true,要在每个使用EL表达式的JSP设定isELIgnored为false, 

    另,引入JSTL可以在本地放置uri="/WEB-INF/c.tld"文件,也可以引入网上的解析文件uri="http://java.sun.com/jsp/jstl/core",同时别忘了需要2个jar包(jstl.jar和standard.jar)

  • 相关阅读:
    动态更新活动条件
    使用本地服务异步执行自定义活动业务逻辑
    隐藏自定义复合活动的内部实现
    如何开发一个基本的复合活动
    HTML5性能之争 —— 单线程:缺点还是特点?
    CDNJS —— Web 上最快的 JavaScript 资源库
    Comfusion 4.1 发布,桌面 Linux 发行
    FreeBSD 9.1 正式版已经可以下载
    Squid Analyzer 5.0 发布,Squid日志统计
    MemSQL 1.8 发布,号称最快的关系数据库
  • 原文地址:https://www.cnblogs.com/onmyway20xx/p/7240315.html
Copyright © 2011-2022 走看看