I\'ve been using prefix mapping for years and decided to switch to suffix
mapping, just to get rid of the /faces
in the url really. I just wanted
to check I\'m
and then I see that everything going through FacesServlet has .xhtml appended to it, so that the browser is requesting .png.xhtml files, .css.xhtml file - is this right?
This only applies to resources included by
and
. This is not related to the change in the URL mapping. This is related to the change from JSF 1.x to JSF 2.x and the change from and
to the aforementioned JSF2 tags.
For your own scripts, stylesheets and other static stuff which is to be served from the public webcontent, you should not manually add the .xhtml
extension. You should not need to change anything with regard to existing static resources.
Only for CSS background images and other Imagine that you have the following and that you're including the then you should be defining the background image URL as follows Or when you're relying on the default library, thus you aren't using the As to the securiry constraint, it is not needed when you're already using the url()
references in CSS files which is to be included using the
tag (and thus not for
/resources
folder structure:WebContent
|-- META-INF
|-- resources
| `-- default
| |-- images
| | `-- background.png
| `-- css
| `-- style.css
|-- WEB-INF
`-- test.xhtml
style.css
in test.xhtml
as followsbody {
background-image: url("#{resource['default:images/background.png']}");
}
library
, then it should rather look like this:WebContent
|-- META-INF
|-- resources
| |-- images
| | `-- background.png
| `-- css
| `-- style.css
|-- WEB-INF
`-- test.xhtml
test.xhtml
:style.css
:body {
background-image: url("#{resource['images/background.png']}");
}
*.xhtml
mapping. The security constraint is intended to prevent the enduser from seeing the raw XHTML source code when the FacesServlet
is mapped on a pattern other then *.xhtml
. The enduser would be able to see the XHTML source code by just removing /faces
part from the URL in case of a /faces/*
mapping or renaming .jsf
to .xhtml
in case of a *.jsf
mapping. Get rid of the security constraint, it makes in your case things worse as you're already using a *.xhtml
mapping which makes it already impossible to see the raw XHTML source code by hacking the URL.