`

tomcat 5 下 el和taglib的问题处理

    博客分类:
  • JSP
 
阅读更多

 

其实不能说让tomcat支持EL语言,tomcat5以后的版本都支持JSP2.0也就是都支持EL语言。但是为什么我们的应用程序发布到tomcat5服务器上后还是不支持EL语言呢,而且甚至不能发布成功。 
这里涉及到web.xml文件的迁移问题 
1、把文件头换成<web-app id="WebApp_ID" version="2.4" 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 java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
2、还是报错,怎么所有的servlet声明在eclipse里面全部报错呢。这里把servlet里的所有节点都按照这个顺序写 
----------------------------------------------- 
    <servlet> 
      <display-name>istFrame</display-name> 
      <servlet-name>istFrameServlet</servlet-name> 
      <servlet-class> 
        com.istqz.istframe.servlet.ISTFrameServlet 
      </servlet-class> 
      <init-param> 
        <param-name>istf-config</param-name> 
        <param-value> 
          /WEB-INF/config/ac-config.xml, 
          /WEB-INF/config/eis-config.xml, 
          /WEB-INF/istf-config.xml 
        </param-value> 
      </init-param> 
      <load-on-startup>1</load-on-startup> 
    </servlet> 
----------------------------------------------- 
3、最可恶的就得算taglib标签声明了,在2.4里面竟然没有taglib这一项,不是2.4就把标签去掉了吧。用大拇趾想想应该不会才对的。所幸在下面的文章里看到原来2.4增加了 
---------------------------------------------- 
    <jsp-config> 
      <taglib> 
        <taglib-uri>http://www.istqz.com</taglib-uri> 
        <taglib-location>/WEB-INF/istf-tag.tld</taglib-location> 
      </taglib> 
    </jsp-config> 
---------------------------------------------- 
4、具体实现el就不用说了..........


bob.marlboro.edu/wiki04/Wiki.jsp?page=LocationOfJspRelatedElementsInDeploymentDescriptor 

Problems when changing Websphere Generated Files from JSTL 2.3 to 2.4 
Sunday, April 11, 2004 

Per the table on bob.marlboro.edu/wiki04/Wiki.jsp?page=JstlJspAndWeb.xmlVersioningIssues I changed the required files to run version 2.4 not 2.3 in Websphere 5.1.1. 

The following modification was made manually to the Web Deployment Descriptor (web.xml). 

<!-- 
Change to use version 2.4, see table on bob.marlboro.edu/wiki04/Wiki.jsp?page=JstlJspAndWeb.xmlVersioningIssues 
<!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"> 
--> 
<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" 
  id="WebApp" > 
In display.jsp the correct changes were made as well to insure we are at 2.4 
In web.xml the first in the file has the error: 
cvc-complex-type.2.4.a: Invalid content starting with element 'taglib'. The content must match '((((((((((((((((((((("http://java.sun.com/xml/ns/j2ee":description){0-UNBOUNDED},("http://java.sun.com/xml/ns/j2ee":display-name){0-UNBOUNDED}),("http://java.sun.com/xml/ns/j2ee":icon){0-UNBOUNDED})|("http://java.sun.com/xml/ns/j2ee":distributable))|("http://java.sun.com/xml/ns/j2ee":context-param))|("http://java.sun.com/xml/ns/j2ee":filter))|("http://java.sun.com/xml/ns/j2ee":filter-mapping))|("http://java.sun.com/xml/ns/j2ee":listener))|("http://java.sun.com/xml/ns/j2ee":servlet))|("http://java.sun.com/xml/ns/j2ee":servlet-mapping))|("http://java.sun.com/xml/ns/j2ee":session-config))|("http://java.sun.com/xml/ns/j2ee":mime-mapping))|("http://java.sun.com/xml/ns/j2ee":welcome-file-list))|("http://java.sun.com/xml/ns/j2ee":error-page))|("http://java.sun.com/xml/ns/j2ee":jsp-config))|("http://java.sun.com/xml/ns/j2ee":security-constraint))|("http://java.sun.com/xml/ns/j2ee":login-config))|("http://java.sun.com/xml/ns/j2ee":security-role))|((((((("http://java.sun.com/xml/ns/j2ee":env-entry){0-UNBOUNDED},("http://java.sun.com/xml/ns/j2ee":ejb-ref){0-UNBOUNDED}),("http://java.sun.com/xml/ns/j2ee":ejb-local-ref){0-UNBOUNDED}),("http://java.sun.com/xml/ns/j2ee":service-ref){0-UNBOUNDED}),("http://java.sun.com/xml/ns/j2ee":resource-ref){0-UNBOUNDED}),("http://java.sun.com/xml/ns/j2ee":resource-env-ref){0-UNBOUNDED}),("http://java.sun.com/xml/ns/j2ee":message-destination-ref){0-UNBOUNDED}))|("http://java.sun.com/xml/ns/j2ee":message-destination))|("http://java.sun.com/xml/ns/j2ee":locale-encoding-mapping-list)){0-UNBOUNDED}'. 


Ok, what bit of stupidity am I demonstarting now? 
-Bill 

Not having access to the full web.xml this is just a guess, but my hunch is that your taglib elements are in the wrong place in the web.xml (e.g. before elements that they need to appear after). I'd suggest either taking a look at the 2.3-level DTD yourself and seeing whether you have the right sequence (you'll find the URL for the DTDin the DOCTYPE above--I know you're trying to set things up 2.4-style, but the 2.3 DTD will probably be easier for you to digest at this point); or paste in the complete web.xml here and I'll take a look. 

I changed it back to 2.3 by uncommenting the 2.3 code and commenting out the 2.4 code. There error went away. I'd like to use the 2.4 version. The following is the erroneous web.xml with the 2.3 commented out: 


<?xml version="1.0" encoding="UTF-8"?> 
<!-- 
Change to use version 2.4, see table on bob.marlboro.edu/wiki04/Wiki.jsp?page=JstlJspAndWeb.xmlVersioningIssues 
<!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"> 
--> 
<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" 
  id="WebApp" > 
   
  <display-name>angevine-2-0</display-name> 
  <servlet> 
    <servlet-name>action</servlet-name> 
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param> 
      <param-name>config</param-name> 
      <param-value>WEB-INF/struts-config.xml</param-value> 
    </init-param> 
    <init-param> 
      <param-name>debug</param-name> 
      <param-value>2</param-value> 
    </init-param> 
    <init-param> 
      <param-name>detail</param-name> 
      <param-value>2</param-value> 
    </init-param> 
    <init-param> 
      <param-name>validate</param-name> 
      <param-value>true</param-value> 
    </init-param> 
    <load-on-startup>2</load-on-startup> 
  </servlet> 
  <servlet-mapping> 
    <servlet-name>action</servlet-name> 
    <url-pattern>*.do</url-pattern> 
  </servlet-mapping> 
  <welcome-file-list> 
    <welcome-file>index.html</welcome-file> 
    <welcome-file>index.htm</welcome-file> 
    <welcome-file>index.jsp</welcome-file> 
    <welcome-file>default.html</welcome-file> 
    <welcome-file>default.htm</welcome-file> 
    <welcome-file>default.jsp</welcome-file> 
  </welcome-file-list> 
  <taglib> 
    <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri> 
    <taglib-location>/WEB-INF/struts-bean.tld</taglib-location> 
  </taglib> 
  <taglib> 
    <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri> 
    <taglib-location>/WEB-INF/struts-html.tld</taglib-location> 
  </taglib> 
  <taglib> 
    <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri> 
    <taglib-location>/WEB-INF/struts-logic.tld</taglib-location> 
  </taglib> 
  <taglib> 
    <taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri> 
    <taglib-location>/WEB-INF/struts-nested.tld</taglib-location> 
  </taglib> 
  <taglib> 
    <taglib-uri>/WEB-INF/struts-template.tld</taglib-uri> 
    <taglib-location>/WEB-INF/struts-template.tld</taglib-location> 
  </taglib> 
  <taglib> 
    <taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri> 
    <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location> 
  </taglib> 
</web-app> 
Ok. To satisfy the 2.4 grammar I think you're going to have to put all the taglib elements under a jsp-config element. That is the hierarchy should look like: 

<web-app ... > 
... 
<jsp-config> 
<!-- taglib elements go at this level --> 
</jsp-config> 
</web-app> 
I added the jsp-config tag set, after changeing to 2.4, and it worked! I missed this in the conversion. It's always the little things...... 

No, there's no way you could've guessed this. It's one of the places where a 2.3 descriptor isn't forward-compatible with the 2.4 grammar, and I hadn't mentioned it before.

标签集:
分享到:
评论

相关推荐

    JSTL详解--EL表达式

    JSTL详解--EL表达式 在 JSP 页面中,使用标签库代替传统...q Standard-1.0 Taglib ( JSTL1.0 )支持 Servlet2.3 和 JSP1.2 规范, Web 应用服务器 Tomcat4 支持这些规范,而它的发布也在 Tomcat 4.1.24 测试通过了。

    el.jar jstl.jar standard.jar(jsp标签所需jar包)

    根据情况选择 如果是tomcat5.5的话3个jar包都要 如果是tomcat6.0的话只需要standard.jar和 jstl.jar

    JAVA WEB 开发详解:XML+XSLT+SERVLET+JSP 深入剖析与实例应用.part5

    第5章 servlet与tomcat 182 5.1 servlet与servlet容器 182 5.2 servlet容器的分类 183 5.3 servlet和其他技术的比较 183 5.4 tomcat介绍 183 5.5 tomcat的安装与配置 184 5.5.1 安装tomcat 185 5.5.2 运行...

    JSTL高级用法

    JSTL标签主要包含核心标签库、格式标签库、SQL标签库、XML标签库和函数标签库共5种标签库。 在使用JSTL标签之前必须在JSP页面的首行使用指令定义标签库的位置和访问前缀,(jstl 1.1)各个标签库的定义如下: 核心...

    JAVA WEB 开发详解:XML+XSLT+SERVLET+JSP 深入剖析与实例应用.part2

    第5章 servlet与tomcat 182 5.1 servlet与servlet容器 182 5.2 servlet容器的分类 183 5.3 servlet和其他技术的比较 183 5.4 tomcat介绍 183 5.5 tomcat的安装与配置 184 5.5.1 安装tomcat 185 5.5.2 运行...

    JAVA WEB 开发详解:XML+XSLT+SERVLET+JSP 深入剖析与实例应用.part4

    第5章 servlet与tomcat 182 5.1 servlet与servlet容器 182 5.2 servlet容器的分类 183 5.3 servlet和其他技术的比较 183 5.4 tomcat介绍 183 5.5 tomcat的安装与配置 184 5.5.1 安装tomcat 185 5.5.2 运行...

    JAVA WEB 开发详解:XML+XSLT+SERVLET+JSP 深入剖析与实例应用.part3

    第5章 servlet与tomcat 182 5.1 servlet与servlet容器 182 5.2 servlet容器的分类 183 5.3 servlet和其他技术的比较 183 5.4 tomcat介绍 183 5.5 tomcat的安装与配置 184 5.5.1 安装tomcat 185 5.5.2 运行...

    网页教程《跟姐姐学JSP》

    3.4. forward和redirect的问题 3.4.1. 绝对路径与相对路径 3.4.1.1. 相对路径 3.4.1.2. 绝对路径 3.4.2. forward导致找不到图片 4. 四个作用域 4.1. 何为作用域 4.2. 例子:在线列表 5. 结合javabean实现CRUD ...

    Java Web编程宝典-十年典藏版.pdf.part2(共2个)

    这些源代码全部经过精心调试,能够在Windows XP、WindowsServer2003及Windows7操作系统下编译和运行。 《Java Web编程宝典(十年典藏版)》适用于Java Web的初学者、编程爱好者,同时也可以作为培训机构、大中专院校...

    jpivot学习总结.doc

    allLevelName 所有级别的名字,它会覆盖其下所有的 Member 的 name 和所有的 Level 的 name 属性的值。 allMemberCaption 例如 : allMemberCaption= “全部产品”这个是在表示层显示的内容 PrimaryKey 通过主键...

Global site tag (gtag.js) - Google Analytics