设为首页 收藏本站
查看: 573|回复: 0

[经验分享] tomcat 5 下 el和taglib的问题处理

[复制链接]

尚未签到

发表于 2017-2-7 08:57:10 | 显示全部楼层 |阅读模式
  其实不能说让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.

标签集:

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-338561-1-1.html 上篇帖子: How tomcat work连载二:简易的Servlet容器 下篇帖子: Tomcat发布为windows服务-转(http://www.javaeye.com/topic/426413)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表