迷失的 JSF 初学者:Linux、Geronimo 和标签库
我将 Geronimo 与 J2EE 5 和 Tomcat 6 结合使用,并尝试使用 JSF 创建一个简单的页面。我将标记库文件 myfaces_core.tld
和 myfaces_html.tld
放入 WEB-INF
中,它可以工作,但只能在 Windows 上使用。在 Linux 下,当我部署 WAR 时,我收到了 IOException
,原因未知。删除这两个标签库文件使部署成为可能。但是当我在浏览器中打开页面时出现错误。它缺少文件 WEB-INF/myfaces_html.tld
,该文件在 JSP 文件的标头中指定。在 MyFaces 的示例中,使用的不是 MyFaces TLD,而是常见的 Sun Java TLD。我已将 URI WEB-INF/myfaces_html.tld
覆盖为 http://java.sun.com/jsf/html
ant,现在我收到错误 绝对uri:http://java.sun.com/jsf/html无法解析在 web.xml 或 jar 文件中与此应用程序一起部署。
我现在迷路了。我是否必须将标签库描述文件放入我的 WAR 中才能使用 JSF 组件?这些文件已经包含在 Geronimo 容器的 MyFaces JAR 中,不是吗?无论平台如何,容器都必须具有相同的行为,或者不需要?我应该如何创建真正独立于平台的简单应用程序?
I use Geronimo with J2EE 5 and Tomcat 6 and I'm trying to create one simple page using JSF. I put the tag library files myfaces_core.tld
and myfaces_html.tld
in WEB-INF
and it works, but just on Windows. Under Linux I got IOException
with an unknown reason when I was deploying the WAR. To remove the two tag library files made the deploy possible. But then I got an error when I was opening the page in browser. It was missing the file WEB-INF/myfaces_html.tld
, which is specified in the header of JSP file. In examples for MyFaces there is used not MyFaces TLD, but common Sun Java TLD. I have overwritten the URI WEB-INF/myfaces_html.tld
to http://java.sun.com/jsf/html
ant now I'm getting the error The absolute uri: http://java.sun.com/jsf/html cannot be resolved in either web.xml or the jar files deployed with this application.
I'm lost now. Must I or must I not put the tag library description files into my WAR to use JSF components? These files are already contained in MyFaces JARs in Geronimo Container, aren't? The container must have the same behavior regardless to platform or it needn't? What shall I do to create my simple application really platform independent?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不应该提取第 3 方标记库的 JAR 文件并将其松散的 TLD 文件放入
/WEB-INF
文件夹中。 TLD 文件应保存在其来源的 JAR 文件中,并且 JAR 文件应保持不变,只需将其放入运行时类路径中即可。任何书籍/教程/论坛建议的其他内容都应该被列入黑名单。清理您的项目结构以删除那些松散的 TLD 文件并撤消与此相关的所有更改,当然也在
web.xml
中(如果有)。为了让 JSF 在 Tomcat 6 上运行,您的
/WEB-INF/lib
文件夹应该只包含两个文件:一个文件代表抽象 API,另一个文件代表具体实现。由于您显然选择使用 MyFaces,因此它将是这两个 JAR 文件(可能在文件名末尾带有版本号,具体取决于):将它们放入
/ WEB-INF/lib
文件夹,它是 web 应用程序默认运行时类路径的一部分。就这样。下一步是在 web 应用的web.xml
中声明并映射FacesServlet
。确保您正在阅读正确的书籍/教程。
You should not be extracting JAR files of 3rd party tag libraries and placing its loose TLD files in the
/WEB-INF
folder. The TLD files should be kept in the JAR files where they originate and the JAR files should be untouched and just be dropped in the runtime classpath. Whatever book/tutorial/forum is suggesting otherwise should be blacklisted.Cleanup your project structure to get rid of those loose TLD files and undo every change related to this, for sure also in the
web.xml
, if any.Your
/WEB-INF/lib
folder should contain just two files in order to get JSF to run on Tomcat 6: one file representing the abstract API and other representing the concrete implementation. As you've apparently chosen to use MyFaces, it'll be those two JAR files (probably with a version number at end of filename, that depends):Drop them in
/WEB-INF/lib
folder which is part of the webapp's default runtime classpath. That's all. Next step would be declaring and mapping theFacesServlet
in your webapp'sweb.xml
.Ensure that you're reading the proper book/tutorial.