其实不能说让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.
标签集:
分享到:
相关推荐
本话题将详细介绍在Tomcat 5.5环境下如何使用JSTL1.1,并重点讲解所需的两个关键JAR包:jstl-1.1.2.jar和standard1.1.2.jar。 首先,我们需要理解JSTL1.1.2.jar的作用。这个JAR包包含了JSTL的核心API,提供了如if、...
9. **错误处理和日志**:Tomcat提供了详细的错误页面和日志系统,帮助开发者调试和诊断问题。 10. **热部署**:Tomcat允许在不中断服务的情况下更新应用程序,这对于开发和测试环境非常有用。 11. **Clustering和...
- Servlet容器:`pager-taglib`需要部署在Servlet容器中运行,如Tomcat,它负责解析JSP标签库和执行业务逻辑。 综上所述,`pager-taglib`提供了一种简单、高效的JSP分页解决方案。通过学习和实践,开发者可以轻松地...
5. **JSTL和EL表达式**:介绍JSP标准标签库(JSTL)和表达式语言(EL),如何简化JSP页面的编程。 6. **会话管理**:如何使用session对象进行用户会话跟踪,实现购物车、登录等功能。 7. **过滤器和监听器**:讲解...
- 支持JSP 2.1规范,提供更强大的EL(Expression Language)和更丰富的taglib库。 - 引入了新的安全管理器,增强了安全性。 - 提供了更好的性能和稳定性。 3. **跨平台兼容性**:Tomcat 6的“WIN for Linux”...
本文将深入探讨EL表达式的基本概念、可能出现的问题及其解决方案,并结合提供的`jstl.jar`和`standard.jar`这两个关键库文件,来进一步理解它们在处理EL表达式中的作用。 EL表达式是JavaServer Pages(JSP)2.0引入...
`jstl-1.2.jar`包含了JSTL的主要实现,而`standard-1.1.2.jar`则包含了EL(Expression Language)和JSTL之间的桥梁——JSTL的Standard Taglib。 当JSP Tomcat7出现JSTL错误时,可能的原因有以下几点: 1. **JAR...
理解每个阶段可以帮助开发者优化代码性能和处理异常。 3. **EL(Expression Language)**:是JSP 2.0引入的表达式语言,简化了在页面中访问JavaBean属性的操作。 **JSF(JavaServer Faces)**是Java EE平台上的...
6. **JSP基础知识**:学习JSP指令(page、include、taglib)、脚本元素(声明、脚本块、表达式)、EL(Expression Language)和JSTL(JavaServer Pages Standard Tag Library)。 7. **MVC模式**:在JavaWeb开发中...
EL 表达式语言是 JSTL 中的重要组成部分,它简化了数据访问和处理过程,提高了 JSP 页面的开发效率。通过使用 EL 表达式,开发者可以更轻松地管理页面中的数据流,并且使得代码更加清晰和易于维护。随着 JSTL 1.1 ...
它包括几个核心标签集,如Core、XML、Functions和Conditional,以及一个表达式语言(EL)组件。JSTL的核心目标是减少在JSP页面上的脚本元素,从而使得页面更易于阅读和维护,提高开发效率。 **在Tomcat中配置JSTL:...
4. **JSP语法与指令**:涵盖了JSP的脚本元素(Scriptlets、表达式、声明)、JSP指令(page、include、taglib),以及EL(Expression Language)和JSTL(JavaServer Pages Standard Tag Library)的使用,这些都是...
- **JSP语法**:包括脚本元素(scriptlets、表达式、声明),指令(page、include、taglib),以及EL(Expression Language)和JSTL(JavaServer Pages Standard Tag Library)。 - **生命周期**:JSP页面会被编译...
1. 将`myTags.tld`和实现类打包到Web应用的`WEB-INF`目录下。 2. 部署应用到服务器,如Tomcat、Jetty等。 3. 访问JSP页面,查看自定义标签是否正确执行并显示预期结果。 **注意事项与扩展** - 自定义标签可以有任意...
在Tomcat 5.5环境下,为了使Struts能够正常工作,需要将上述jar包复制到Tomcat的`lib`目录下,或者直接在应用的`WEB-INF/lib`目录下放置,这样它们会在应用启动时被自动加载。这样做可以确保应用运行时能够找到所有...
5. **Taglib处理增强**:包括高级池和标签插件。 6. **平台集成**:Windows和Unix的原生包装器支持。 **Apache Tomcat 4.x** Tomcat 4.x 实现了全新的servlet容器(Catalina),支持Servlet 2.3和JSP 1.2。主要改进...
JSP的核心概念包括JSP指令(如page、include和taglib)、JSP动作(如jsp:include、jsp:forward和jsp:params)以及EL(Expression Language)和JSTL(JavaServer Pages Standard Tag Library)。 MySQL是广泛使用的...
5. JSTL(JavaServer Pages Standard Tag Library):提供一套标准标签库,简化JSP的开发,比如c标签库用于循环和条件判断,fmt标签库处理日期和格式化。 三、Tomcat与JSP的结合 1. 部署应用程序:将打包好的WAR...
描述虽然简洁,但我们可以推测其核心内容可能包括如何在Tomcat 7.0环境下配置和运行JSP应用程序,以及可能出现的问题和解决方法。 在Java Web开发中,JSP是一种动态网页技术,它允许开发者在HTML页面中嵌入Java代码...