【发布时间】:2015-02-09 18:04:57
【问题描述】:
我正在尝试设置一个允许通过电子邮件地址查询用户的 REST 端点。电子邮件地址是路径的最后一部分,因此 Spring 将 foo@example.com 视为值 foo@example 并截断扩展名 .com。
我在这里发现了一个类似的问题Spring MVC @PathVariable with dot (.) is getting truncated
但是,我有一个使用AbstractAnnotationConfigDispatcherServletInitializer 和WebMvcConfigurerAdapter 的基于注释的配置。由于我没有 xml 配置,因此此解决方案不适用于我:
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="useDefaultSuffixPattern" value="false" />
</bean>
我也试过这个使用正则表达式的解决方案,但也没有用。
@RequestMapping(value = "user/by-email/{email:.+}")
有谁知道如何在没有xml的情况下关闭后缀模式截断?
【问题讨论】:
-
this 对你有帮助吗
标签: java spring rest spring-mvc spring-annotations