区分大小写的网址 [英] Case Sensitive URL

查看:132
本文介绍了区分大小写的网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开设了一个小型网站.

I've launched a small website.

我发现用户遇到错误,经调查发现,他们尝试使用的URL都是小写,而我将它们声明为camelCase.

I have found that I'm getting errors by users and upon investigation see that the urls they are trying to use are all lowercase whereas I've declared them as camelCase.

我不知道为什么这些用户应该尝试使用所有小写字母(我无法想象有人会花时间进行更改:

I've no idea why these users should be trying to use all lower case (I can't imagine anyone would actually take the time to change:

www.mysite.com/myAction.do

www.mysite.com/myaction.do

但是无论如何我都不会想到这会被改变.还有其他人在以下地方遇到过这种情况吗?

However I can't think of anyway this would otherwise be changed. Has anyone else experienced this where:

yourAction.do用作youraction.do吗?

yourAction.do in your mapping file is then attempted to be accessed by users as youraction.do ?

我正在使用Struts2.3.1,sitemesh 2.4.2-我从未听说过或遇到过这种情况,并且希望就如果任何人遇到相同或相似的情况可能导致的原因提出建议.

I'm using Struts2.3.1, sitemesh 2.4.2 - I've never heard of or encountered such a situation and would like advice on what may be causing it if any of you have encountered the same or similar.

是否存在任何将camelCase.do重新映射到camelcase.do的浏览器?无论出于什么原因.

Are there any browsers out there that remap camelCase.do to camelcase.do ? For whatever reason.

我能想到的唯一解决方案"(两个非常丑陋和不雅观的解决方法中最好的)是在struts.xml中复制动作映射.

The only 'solution' I can think of (the best out of two very ugly and inelegant workarounds) is to duplicate the action mappings in struts.xml

<action name="myAction" class="myActionClass" />
<action name="myaction" class="myActionClass" /> //added extra but what a 'dumb' solution

是否可以对方法做同样的事情?

Is is possible to do the same with methods?

因此:

myAction!clear.do

仍将与URL正确映射:

will still be correctly mapped with the URL:

myaction!clEAr.do 

?

通过重新读取错误日志,我注意到导致大多数错误的是ULR中的错误情况"方法.

I notice from re-reading my error logs that it's the 'wrong case' method in the ULR which is causing most errors.

推荐答案

您可以将regex模式匹配器与(?i)一起使用,以将匹配标志嵌入"正则表达式主体中.例如

You can use regex pattern matcher with (?i) to "embed" the matching flag(s) in the regex body. For example

<constant name="struts.patternMatcher" value="regex" />

<action name="{(?i)myaction}" class="myActionClass" /> 

这篇关于区分大小写的网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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