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

         在使用jsp的el表达式时,发现tomcat 5对其不解析。按原样输出如${items}.
    原样把tomcat 的jsp例子拷过来还是如此。web.xml里和lib里的配置都配好了。找了很久才发现web.xml文件使用的是servlet 2.3版本的声明的问题。el在servlet 2.3中默认是不启用的。

    servlet 2.3的

    <?xml version="1.0" encoding="UTF-8"?>
    <!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 id="WebApp_ID">

    tomcat自带的 servlet 2.4的。

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

    把web.xml的声明部分改为2.4的即可。
    还有就是如果使用了<taglib>标签就需要加<jsp-config>父标签。具体内容看jsp2.0和servlet2.4规范

     <jsp-config>
      <taglib>
        <taglib-uri>/tags/struts-bean.tld</taglib-uri>
        <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
      </taglib>
      </jsp-config>

         在使用jsp的el表达式时,发现tomcat 5对其不解析。按原样输出如${items}.
    原样把tomcat 的jsp例子拷过来还是如此。web.xml里和lib里的配置都配好了。找了很久才发现web.xml文件使用的是servlet 2.3版本的声明的问题。el在servlet 2.3中默认是不启用的。

    servlet 2.3的

    <?xml version="1.0" encoding="UTF-8"?>
    <!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 id="WebApp_ID">

    tomcat自带的 servlet 2.4的。

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

    把web.xml的声明部分改为2.4的即可。
    还有就是如果使用了<taglib>标签就需要加<jsp-config>父标签。具体内容看jsp2.0和servlet2.4规范

     <jsp-config>
      <taglib>
        <taglib-uri>/tags/struts-bean.tld</taglib-uri>
        <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
      </taglib>
      </jsp-config>

  • 相关阅读:
    apache重写规则自动追加查询参数QSA
    错误代码2104:无法下载Silverlight应用程序。请查看Web服务器设置
    eclipse的shell相关插件
    二叉树及排序二叉树的相关操作汇总
    约瑟夫环
    c++ 输入一行字符串
    类对象做函数参数(传值和传引用)
    运算符重载(=和+)
    char型字符串(数组)与string型字符串 指针与引用
    一维和二维数组 动态内存分配
  • 原文地址:https://www.cnblogs.com/cookray/p/2074937.html
Copyright © 2011-2022 走看看