Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
新行和Spring';s simplerlhandermapping_Spring_Spring Mvc - Fatal编程技术网

新行和Spring';s simplerlhandermapping

新行和Spring';s simplerlhandermapping,spring,spring-mvc,Spring,Spring Mvc,我最近将我的应用程序从Spring2.5.6升级到Spring3.0.0。几天后,我注意到我的一些页面不再正常工作。问题似乎是我的UserContent.do控制器 UserContent.do使用simplerlhandermapping映射进行映射。看起来是这样的: <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property

我最近将我的应用程序从Spring2.5.6升级到Spring3.0.0。几天后,我注意到我的一些页面不再正常工作。问题似乎是我的UserContent.do控制器

UserContent.do使用
simplerlhandermapping
映射进行映射。看起来是这样的:

<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
 <props>
  <prop key="/*/UserContent.do">UserContentController</prop>
 </props>
</property>
</bean>
第三种情况才是问题所在。由于某些原因,“\r\n”似乎不再与Spring 3中的*匹配。它似乎在Spring2.5.6中仍然有效


我计划不再允许用户在该位置输入换行符。这是一个疏忽开始。然而,出于SEO原因,我希望这些URL继续工作。有没有一种方法可以在Spring 3中用URL编码的换行符映射URL?

似乎最简单的解决方法是使用
/**/UserContent.do
(它还将匹配中间的
/

编辑:


更优雅的方法是,不匹配
/
的:
/{foo:(?s:.*)/UserContent.do
(使用
{name:regexp}
语法声明带有自定义regexp的路径变量,并使用
(?s:X)
打开
模式.DOTALL
标志)

Whoa,SimplerlHandlerMapping支持正则表达式??“这有记录吗?”船长:有意思的问题。有文献记载,
simplerlhandermapping
使用
AntPathMatcher
,并且
AntPathMatcher
可以处理路径变量。
AntPathMatcher
可以处理自定义正则表达式这一事实似乎只在JIRA中提到过(,他们还建议将其作为解决其他一些问题的方法)
http://mysite.com/foo/UserContent.do
http://mysite.com/bob/UserContent.do
http://mysite.com/foo%0a%0dbob/UserContent.do