将 JSF 前缀更改为后缀映射迫使我在 CSS 背景图像上重新应用映射 [英] Changing JSF prefix to suffix mapping forces me to reapply the mapping on CSS background images

查看:10
本文介绍了将 JSF 前缀更改为后缀映射迫使我在 CSS 背景图像上重新应用映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我多年来一直在使用前缀映射,并决定改用后缀映射,只是为了真正摆脱 url 中的 /faces .我只是想在我给自己挖一个洞之前检查我是否朝着正确的方向前进有一些意想不到的事情正在发生.我改变了这个:

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 going in the right direction before I dig myself a hole as there are a few unexpected things going on. I changed from this:

<servlet-mapping>
    <servlet-name>FacesServlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
</servlet-mapping>

为此:

<servlet-mapping>
    <servlet-name>FacesServlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

然后我看到所有通过 FacesServlet 的东西都有 .xhtml附加到它,以便浏览器请求 background.png.xhtml 文件,style.css.xhtml 文件 - 是这样吗?我想这叫做后缀映射,但对我来说它看起来有点不整洁,我试图说服自己这是要走的路.

And then I see that everything going through FacesServlet has .xhtml appended to it, so that the browser is requesting background.png.xhtml files, style.css.xhtml file - is this right? It is called suffix mapping I suppose, but it looks a bit untidy to me and I'm trying to convince myself it's the way to go.

在引用 URI 的 CSS 文件中,我还必须附加 .xhtml:

In my CSS files where an URI is referenced I also have to append .xhtml:

background-image: url(images/background.png.xhtml);

然后我看到了一个来自 BalusC 的帖子,它提供了一个解决方案来防止无需通过 FacesServlet 下载资源:

Then I saw a post from BalusC that gives a solution to prevent the download of resources without going via FacesServlet:

<security-constraint>
    <display-name>Restrict raw XHTML docs</display-name>
    <web-resource-collection>
        <web-resource-name>XHTML</web-resource-name>
        <url-pattern>*.xhtml</url-pattern>
    </web-resource-collection>
    <auth-constraint/>
</security-constraint>

当我添加这个时,只有真正的 .xhtml 文件加载到页面上,所有其他资源(尽管附加了 .xhtml)不显示.

When I add this then only real .xhtml files load on the page, all other resources (despite having .xhtml appended) do not display.

我只想知道:

  1. 这是将 .xhtml 附加到一切正常吗(对不起,如果这些年最愚蠢的问题)

  1. Is this appending .xhtml to everything normal (sorry if the years silliest question)

为什么restrict raw xhtml docs"安全约束会阻止资源,例如加载中的 CSS、JavaScript 和图像?

Why does the 'restrict raw xhtml docs' security constraint prevent resource such as CSS, JavaScript and images from loading?

感谢您的任何反馈.我在 Glassfish 3.1 上使用 Mojarra 2.1.2.

Thanks for any feedback. I am using Mojarra 2.1.2 on Glassfish 3.1.

推荐答案

然后我看到通过 FacesServlet 的所有内容都附加了 .xhtml,因此浏览器正在请求 .png.xhtml 文件、.css.xhtml 文件 - 对吗?

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?

这仅适用于 包含的资源.这与网址映射的变化无关.这与从 JSF 1.x 到 JSF 2.x 的变化以及从

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆