JSF 2.0 EL tags don't render in browser

筅森魡賤 提交于 2019-12-07 15:28:28
Jonathan S. Fisher

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?

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

EDIT2: Add this to your web.xml:

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

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: 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.

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>

Then your home page would be http://localhost/app/index.jsf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!