tomcat 5 下 el和taglib的问题处理

 

其实不能说让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.

标签集:
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值