And*_*daP 3 jsf look-and-feel primefaces jsf-2 login-page
我在我的网络应用程序中使用PrimeFaces 3.4,对于特定页面,控件不会与普通的PrimeFaces皮肤一起显示:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>VMS login</title>
</h:head>
<h:body>
<h:form id="loginForm">
<p:messages id="messages" showDetail="true" autoUpdate="true" closable="true" />
<p:panel header="#{msgs['login.title']}">
<p:panelGrid id="loginPanel" columns="2">
<h:outputText value="#{msgs['login.username']}" />
<p:inputText id="j_username" value="#{loginFormBean.userName}" required="true"></p:inputText>
<p:message for="j_username" ></p:message>
<h:outputText value="#{msgs['login.password']}" />
<p:password id="j_password" value="#{loginFormBean.password}" required="true" feedback="false"></p:password>
<p:message for="j_password"></p:message>
<p:commandButton action="#{loginController.loginUsingSpringAuthenticationManager}" value="#{msgs['login.button']}" update="loginForm" ajax="true"></p:commandButton>
</p:panelGrid>
</p:panel>
</h:form>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
这输出到:

面板应该有一个标题,依此类推.
有趣的是,在我<p:layout>在布局中使用不同面板的另一个页面中,它们显示正常的PrimeFaces外观和感觉.
我究竟做错了什么?谢谢
鉴于它只发生在登录页面上,当认证机制也启动对CSS/JS /图像文件等JSF资源的请求并将它们重定向到登录页面时,就会发生这种情况.然后,webbrowser将检索登录页面的HTML表示而不是具体资源.如果您已经调查了webbrowser的开发人员工具集中的HTTP流量,那么您也应该注意到这一点.
如果您正在使用servlet过滤器进行自行开发的身份验证,那么您需要告诉过滤器不要将它们重定向到登录页面,而只是继续它们.它是那些/javax.faces.resource/*URL(您可以将该URL路径作为常量ResourceHandler#RESOURCE_IDENTIFIER).
if (request.getRequestURI().startsWith(request.getContextPath() + ResourceHandler.RESOURCE_IDENTIFIER)) {
chain.doFilter(request, response);
return;
}
// ...
Run Code Online (Sandbox Code Playgroud)
或者,如果您正在使用容器管理的身份验证,那么您应该添加/javax.faces.resource/*到允许的URL,这些URL应该从登录检查中跳过:
<security-constraint>
<web-resource-collection>
<web-resource-name>Allowed resources</web-resource-name>
<url-pattern>/javax.faces.resource/*</url-pattern>
</web-resource-collection>
<!-- No Auth Contraint! -->
</security-constraint>
Run Code Online (Sandbox Code Playgroud)
或者当您使用像Spring Security这样的第三方认证框架时,您需要通过以下方式告诉它(假设3.1.0或更新版本)
<http security="none" pattern="/javax.faces.resource/**" />
Run Code Online (Sandbox Code Playgroud)
或者当您使用PicketLink时,请参阅基于PrimeFaces的应用程序,PicketLink不会在登录页面中显示样式.
| 归档时间: |
|
| 查看次数: |
1583 次 |
| 最近记录: |