Given that this only happens on the login page, this can happen when the authentication mechanism also triggers requests for JSF resources, such as CSS / JS / image files, and also redirects them to the login page. The web browser then received an HTML representation of the login page instead of specific resources. If you examined HTTP traffic in the webbrowser developer toolkit, you should also have noticed this.
If you are using self-service authentication with a servlet filter, you need to tell the filter so that it does not redirect them to the login page, just keep going. These are the /javax.faces.resource/* URLs (you can get this URL as ResourceHandler#RESOURCE_IDENTIFIER constant).
if (request.getRequestURI().startsWith(request.getContextPath() + ResourceHandler.RESOURCE_IDENTIFIER)) { chain.doFilter(request, response); return; }
Or, if you are using container-managed authentication, add /javax.faces.resource/* to the allowed URLs that you should skip from the login check:
<security-constraint> <web-resource-collection> <web-resource-name>Allowed resources</web-resource-name> <url-pattern>/javax.faces.resource/*</url-pattern> </web-resource-collection> </security-constraint>
See also Exclude css and image resources in web.xml Security Limitations .
Or when you use a third-party authentication system such as Spring Security, you need to say it like this (assuming 3.1.0 or later)
<http security="none" pattern="/javax.faces.resource/**" />
See also Spring Security 3.0.5 .
Or, when you use PicketLink, see a PrimeFaces-based application using PicketLink does not display the style on the login page .
source share