开发者

JSF2: Tags not rendered but the usual "fixes" doesn't cut it

开发者 https://www.devze.com 2023-04-12 16:02 出处:网络
My problem is similar to: JSF tags not rendered, JSf tags not being rendered and also JSF tags not being rendered as HTML no suggestion there helped me.

My problem is similar to: JSF tags not rendered, JSf tags not being rendered and also JSF tags not being rendered as HTML no suggestion there helped me.

Basically the problem is that regardless of going through a welcome page or not the page is not rendered. IE tries to download the file and chrome basically just skips all the jsf tags. It's obvious that it wasn't translated by the framework but I don't understand why.

The back story is that I did a pilot for a conversion of a system from jsf 1.2 into jsf2. The pilot was successful I managed to get it to work in the pilot branch. However when I'm trying to achieve the same thing for real this time I can't get it to work.

The usual problem seems to be (accordingly to veteran answerer BalusC):

The page URL did not match the url-pattern of the FacesServlet, thus it had not any chance to parse the tags. OR: The xmlns declarations for JSF components are missing in tag, thus it was treated as plaintext.

The usual fixes seems to be: Include xmlns in html declaration (I have this in both web.xml and the .xhtml files) Include or modify Faces Servlet Mapping in web.xml. I can however find no fault in mine. I also tried switching out /faces/* to *.xhtml. Parts that I see as relevant in web.xml included below (Whole file is big, this is a big system):

Part of web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_5.xsd"
    version="2.5">

<context-param>
    <description>
        Tell the runtime where we are in the project development
        lifecycle.
    </description>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
</context-param>

<context-param>
    <param-name>facelets.DEVELOPMENT</param-name>
    <param-value>true</param-value>
</context-param>
    <context-param>
    <param-name>com.sun.faces.expressionFactory</param-name>
    <param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
  <servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
<url-pattern>*.xhtml</url-pattern>

 <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.xhtml</param-value&g开发者_如何转开发t;
  </context-param>
<welcome-file-list id="default">
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
    </welcome-file-list>

I'm aware that the welcome file is a html file but this worked in the pilot. That file uses

<body bgcolor="#FFFFFF" onload="window.location='portal/login/login.jsf'">
</body>

To get things going. if I manually type the adress in to some random test page containing little and simple code the problem still occurs so the problem feels unrelated to welcome page.

Will gladly assist with any additional information and I'm really stuck here in a bad spot. Thanks for reading.


Resolved by editing faces-config to include xmlns:xsi.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号