本文介绍了当 url 包含分号时,在 Spring 5 中获得 500 响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我最近从 Spring 3 升级到 Spring.早些时候,当 url 值包含分号时,我能够发布和获取资源.但升级后我收到 500 错误.以下是我的获取请求
I have recently upgraded to Spring from Spring 3. Earlier i was able to post and get resources when the url values contained a semicolon. But after upgrade i am getting 500 error. Below is my get request
/rest/logindomains/grouptorolemapping/13/Atl;BasGroup
/rest/logindomains/grouptorolemapping/13/Atl;BasGroup
有人知道如何解决这个问题吗?
Does anyone know how to resolve this issue?
推荐答案
要在 url 中启用分号,您必须调整 UrlPathHelper
.例如:
For enabling semicolon in url u must tune UrlPathHelper
. For example:
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
UrlPathHelper urlPathHelper = new UrlPathHelper();
urlPathHelper.setRemoveSemicolonContent(false);
configurer.setUrlPathHelper(urlPathHelper);
}
}
这篇关于当 url 包含分号时,在 Spring 5 中获得 500 响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!