当模板客户端位于子目录中时获取 java.io.FileNotFoundException
我正在尝试导航到一个管理页面,该页面在 webcontent 文件夹下有一个子目录并收到 java.io.FileNotFoundException。使用 Glassfish 3.1.1。
我
war File:
index.xhtml
login.xhtml
/admin/admin.xhtml
使用的链接是:
<h:link value="Admin" outcome="admin/admin.xhtml"/>
我希望隐式导航能够处理这个问题?
预先感谢,
斯科特
I am trying to navigate to an administration page which has a sub directory under the webcontent folder and receiving an java.io.FileNotFoundException. Using Glassfish 3.1.1.
My
war File:
index.xhtml
login.xhtml
/admin/admin.xhtml
the link i am using is:
<h:link value="Admin" outcome="admin/admin.xhtml"/>
I was hoping implicit naviagtion would be able to handle this?
Thanks in advance,
Scott
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的
看起来非常好,尽管我只是删除.xhtml
扩展名以最大程度地减少 JSF 已经为您处理的样板文件和 FacesServlet 映射的歧义。您需要阅读您收到的
FileNotFoundException
消息。我想说的是,它实际上指向您在admin/admin.xhtml
的
中使用的模板文件。您需要在其中指定绝对路径,即以/
开头,以便相对于 Web 内容的根目录进行解析,否则相对于当前模板客户端的位置进行解析。例如,不是这样:
它将搜索
/admin/WEB-INF/admintemplate.xhtml
,而是这样:请注意,这与隐式导航无关。直接打开页面时也会遇到完全相同的问题。
Your
<h:link>
looks perfectly fine, although I would just trim off the.xhtml
extension to minimize boilerplate and FacesServlet mapping ambiguity which JSF already takes care of for you.You need to read the message of the
FileNotFoundException
which you got there. My cents on that it actually points to the template file which you're using in<ui:composition template>
ofadmin/admin.xhtml
. You'd like to specify an absolute path in there, i.e. starting with/
, so that it's resolved relative to the root of the web content, otherwise it's resolved relative to the location of the current template client.E.g. thus not so:
which would search for
/admin/WEB-INF/admintemplate.xhtml
, but rather so:Note that this is not related to implicit navigation. You would have exactly the same problem when opening the page directly.