忽略漂亮脸模式中的大小写

发布于 2024-12-18 04:44:25 字数 429 浏览 1 评论 0原文

如果您按如下方式定义了 url 映射:

@URLMapping(id = "myPage", pattern = "/myPage", viewId = "/faces/pages/myPage.xhtml")

如果您尝试将 url 输入为:

http:localhost:8080/myPage

这会正常工作,但如果您将大小写更改为:

http:localhost:8080/mypage

http:localhost:8080/MYPAGE

则不会工作,它不会找到页面,所以有没有办法忽略模式中的大小写,或者 PrettyFaces 还不支持这样的事情,如果不支持,那么请建议一个解决方法。

if you defined a url mapping as follows:

@URLMapping(id = "myPage", pattern = "/myPage", viewId = "/faces/pages/myPage.xhtml")

if you tried to enter the url as:

http:localhost:8080/myPage

this will work fine, but if you changed the case to:

http:localhost:8080/mypage

or http:localhost:8080/MYPAGE

it won't work, it won't find the page, so is there's a way to ignore the case in the pattern, or such thing is not supported in PrettyFaces yet, if not supported, then please suggest a workaround.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泪冰清 2024-12-25 04:44:25

PrettyFaces 目前不直接支持类似的功能。但是您可以通过一个简单的解决方法来实现类似的效果:

将映射更改为完全小写的 URL:

@URLMapping(id = "myPage", pattern = "/mypage", viewId = "/faces/pages/myPage.xhtml")

然后添加执行小写转换的重写规则:

<rewrite match="(?i)/mypage" toCase="lowercase" redirect="chain" />

我认为这应该可以正常工作。您还可以尝试构建更通用的模式,这样您就不必为每个映射重复重写规则。

Something like this is currently not directly supported with PrettyFaces. But you could achieve something like this with a simple workaround:

Change your mapping to a completely lowercase URL:

@URLMapping(id = "myPage", pattern = "/mypage", viewId = "/faces/pages/myPage.xhtml")

And then add a rewrite rule that performs the lowercase transformation:

<rewrite match="(?i)/mypage" toCase="lowercase" redirect="chain" />

I think this should work fine. You could also try to build a more general pattern so that you don't have to repeat the rewrite rule for every mapping.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文