JSF 2.0 EL标签不会在浏览器中呈现 [英] JSF 2.0 EL tags don't render in browser

查看:119
本文介绍了JSF 2.0 EL标签不会在浏览器中呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的 index.html 文件,其中包含JSF: http://pastie.org/3755252

The following is my index.html file which contains the JSF: http://pastie.org/3755252

当我选择运行为>在Eclipse Indigo中运行服务器(Tomcat 7.0.12)我得到一个仅显示以下内容的页面:

When I choose Run as > Run on Server (Tomcat 7.0.12) in Eclipse Indigo I get a page which says only the following:

You have login attempts left.

Chrome中也是如此。虽然在查看页面的源代码之后,它显示的就像我在Eclipse中编写的(以前的pastie文件),但它似乎应该被翻译成html。

The same happens in Chrome. Although after looking at the source of the page, it displayed just as I have it written in Eclipse (the previous pastie file), but it seems like it should be translated to html.

这是我的Member.java文件: http://pastie.org/3755277
和这是我的web.xml: http://pastie.org/3755284

This is my Member.java file: http://pastie.org/3755277 And here is my web.xml: http://pastie.org/3755284

它曾经工作,之前我注意到我正在混合JSF 2.0与JSF1。*语法。然后我将* .jsp更改为* .html,它不起作用。

It used to work, before I noticed I was mixing JSF 2.0 with JSF1.* syntax. Then I changed my *.jsp to *.html and it doesn't work.

推荐答案

Pastie似乎被关闭(我无法读取您的文件)...但是Tomcat不是一个完整的Java EE容器。你需要Mojarra运行时。你有没有包含在你的版本?

Pastie seems to be down (I can't read your files)... but Tomcat isn't a full Java EE container. You'd need the Mojarra runtime. Do you have that included in your build?

编辑:NM回来了。我在web.xml中看到JSF servlet,所以你可能会忽略这个答案。

NM it's back. I see the JSF servlet in your web.xml, so you may disregard this answer.

EDIT2:将它添加到你的web.xml中:

Add this to your web.xml:

 <context-param>
  <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
  <param-value>.xhtml</param-value>
 </context-param>

然后将.html文件重命名为.xhtml。我有一种感觉,servlet不知道应该使用JSF呈现你的文件。

Then rename your .html files to .xhtml. I have a feeling the servlet didn't know it was supposed to render your files using JSF.

EDIT3:所以我认为发生了什么是你的混淆服务器是否或不应该使用Faces渲染页面。您的URL栏中的URL是localhost / app / faces / index.html,它与文件完全匹配。那么应该做一个sendfile还是应该通过servlet来运行它?重命名为.xhtml可能工作的原因是因为内部知道必须将.html请求映射到.xhtml文件。

So I think what's happening is your confusing the server on whether or not it should render the page using Faces. You're URL in your url bar is "localhost/app/faces/index.html" which matches a file exactly. So should it do a sendfile or should it run it through the servlet? The reason why renaming to .xhtml likely worked was because internally it knew it had to map a .html request to a .xhtml file.

所以也许尝试将您的文件重命名为.html5,然后将其设置在您的web.xml中:

So maybe try renaming your files to .html5, then set this in your web.xml:

 <context-param>
  <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
  <param-value>.html5</param-value>
 </context-param>

我认为任何扩展程序都可以工作...你也可以这样做:

I think any extension will work... You could also do this combination:

  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
  </servlet-mapping>
  <context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.html</param-value>
  </context-param>

然后你的主页将是 http:// localhost / app / index .jsf

这篇关于JSF 2.0 EL标签不会在浏览器中呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆