Skip to content

Commit e24e768

Browse files
committed
SPR-6164 - a Uri Value is incorrectly extracted if it contains '.'.
1 parent 64ded04 commit e24e768

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/UriTemplateServletAnnotationControllerTests.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,29 @@ protected WebApplicationContext createWebApplicationContext(WebApplicationContex
235235
servlet.init(new MockServletConfig());
236236
}
237237

238+
@Test
239+
public void noDefaultSuffixPattern() throws Exception {
240+
servlet = new DispatcherServlet() {
241+
@Override
242+
protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent)
243+
throws BeansException {
244+
GenericWebApplicationContext wac = new GenericWebApplicationContext();
245+
wac.registerBeanDefinition("controller", new RootBeanDefinition(ImplicitSubPathController.class));
246+
RootBeanDefinition mappingDef = new RootBeanDefinition(DefaultAnnotationHandlerMapping.class);
247+
mappingDef.getPropertyValues().addPropertyValue("useDefaultSuffixPattern", false);
248+
wac.registerBeanDefinition("handlerMapping", mappingDef);
249+
wac.refresh();
250+
return wac;
251+
}
252+
};
253+
servlet.init(new MockServletConfig());
254+
255+
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/hotels/hotel.with.dot");
256+
MockHttpServletResponse response = new MockHttpServletResponse();
257+
servlet.service(request, response);
258+
assertEquals("test-hotel.with.dot", response.getContentAsString());
259+
}
260+
238261
/*
239262
* Controllers
240263
*/
@@ -406,5 +429,4 @@ public void remove(@PathVariable long hotelId, Writer writer) {
406429
}
407430
}
408431

409-
410432
}

0 commit comments

Comments
 (0)