jsf页面中的空白页 [英] Blank page in jsf page
问题描述
当我尝试打开页面时,我有一个空白页 http://localhost:8084/Gpsi-worked/admin.xhtml ,但是当我尝试此操作时 http://localhost :8084/Gpsi-worked/faces/admin.xhtml 可以解决问题,我在项目中使用了模板.
I have a blank page when i try to open my page http://localhost:8084/Gpsi-worked/admin.xhtml but when i try this http://localhost:8084/Gpsi-worked/faces/admin.xhtml that work where is the problem, im using template in my project.
推荐答案
这是因为FacesServlet
映射到/faces/*
而不是*.xhtml
的URL模式上. FacesServlet
是负责执行所有JSF工作的人员.对JSF页面的所有请求都必须调用FacesServlet
.然后它将解析XML模板中的Facelets和JSF标记并生成HTML代码.右键单击Web浏览器中的空白页面,然后选择查看源代码.您将看到所有JSF标记均未解析. Web浏览器不了解JSF标记,仅了解HTML.
That's because the FacesServlet
is mapped on an URL pattern of /faces/*
instead of *.xhtml
. The FacesServlet
is the one responsible for doing all the JSF works. All requests to JSF pages have to invoke the FacesServlet
. It will then parse the Facelets and JSF tags in the XML template and generate HTML code. Rightclick the blank page in your webbrowser and choose View Source. You'll see that all JSF tags are left unparsed. The webbrowser doesn't understand JSF tags, it only understands HTML.
要摆脱/faces/*
路径,您需要进行更改
In order to get rid of the /faces/*
path, you need to change
<url-pattern>/faces/*</url-pattern>
到
<url-pattern>*.xhtml</url-pattern>
这是唯一的(次要)警告,您不能在不调用FacesServlet
的情况下再提供普通的.xhtml
文件,但实际上这些文件实际上仍应作为.html
;)
This has the only (minor) caveat that you cannot serve plain .xhtml
files anymore without invoking the FacesServlet
, but those files should actually be served as .html
anyway ;)
这篇关于jsf页面中的空白页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!