¿ø¹® : http://stackoverflow.com/questions/24946322/spring-pathvariable-without-ending-slash-string-with-ip-address
Áú¹®
Áú¹®ÀÚ´Â ÀÚ½ÅÀÇ ÄÁÆ®·Ñ·¯¿¡ ¾Æ·¡¿Í °°Àº @RequestMapping À» °®´Â ¸Þ¼µå°¡ Çϳª Àִµ¥,
ÀÌ´Â @PathVariable ·Î IP ÁÖ¼Ò¸¦ ¹Þ´Â ³ÑÀ̶ó ÇÑ´Ù.
±Ùµ¥, °ªÀ» ³Ñ±â±â À§ÇØ http://localhost:8080/test/pc/json/getPCs/192.168.200.1 ÁÖ¼Ò·Î Á¢±ÙÇغôõ´Ï,
·Î±×¿¡ ¾Æ·¡Ã³·³ ¸¶Áö¸· . ÀÌÈÄ·Î À߸®´Â Çö»óÀÌ ³ªÅ¸³´Ù°í Çß´Ù.
INFO : net.example.test.PCController - Server addres: 192.168.200
±×·¡¼ ¿äû URL ÀÇ ¸¶Áö¸·¿¡ / ¸¦ ³Ö¾ú´õ´Ï http://localhost:8080/test/pc/json/getPCs/192.168.200.1/
¾Æ·¡ ·Î±×¿Í °°ÀÌ Á¤»óÀûÀ¸·Î 󸮵Ǿú´Ù°í ÇÑ´Ù.
INFO : net.example.test.PCController - Server addres: 192.168.200.1
¸¶Áö¸·¿¡ ½½·¯½Ã(/) ¾øÀÌ ÇÒ ¼ö ÀÖ´Â ¹æ¹ýÀÌ ¾ø³Ä°í ¹¯´Âµ¥...
´äº¯
PatternsRequestCondition ÀνºÅϽº »ý¼ºÀ» À§ÇÑ RequestMappingHandlerMapping ȯ°æ¿¡
suffix ¸ÅÄ¡¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ¼³Á¤ÇØÁÖ¸é µÈ´Ù°í ÇÑ´Ù.
WebMvcConfigurationSupport ¸¦ È®ÀåÇÑ ¼³Á¤¿¡¼ ¾Æ·¡¿Í °°ÀÌ requestMappingHandlerMapping() ¸Þ¼µå¸¦ ¿À¹ö¶óÀ̵åÇÏ¿©
setUseSuffixPatternMatch() °ªÀ» false ·Î ÁöÁ¤ÇÏ¸é µÈ´Ù°í ÇÑ´Ù.
setUseSuffixPatternMatch() ÀÇ ±âº»°ªÀº true.
RequestMappingHandlerMapping ÀÇ ¸Å´º¾óÀ» º¸¸é
http://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.html
¾Æ·¡¿Í °°ÀÌ µÇ¾î Àִµ¥,
org.springframework.web.servlet.mvc.method.annotation
RequestMappingHandlerMapping
Creates RequestMappingInfo instances from type and method-level @RequestMapping annotations in @Controller classes.
setUseSuffixPatternMatch
Whether to use suffix pattern match (".*") when matching patterns to requests.
If enabled a method mapped to "/users" also matches to "/users.*".
The default value is true.
Also see setUseRegisteredSuffixPatternMatch(boolean) for more fine-grained control over specific suffixes to allow.
setUseSuffixPatternMatch() °ªÀÌ default ÀÎ true ÀÎ °æ¿ì, suffix ÆÐÅÏ(".*") ¸ÅÄ¡¸¦ »ç¿ëÇÑ´Ù´Â °Çµ¥,
±×·¸°Ô µÇ¸é /users µµ Çã¿ëµÇ¸é¼ /users.* µµ Çã¿ëµÈ´Ù´Â °ÍÀÌ´Ù.
±×·¡¼, ½ÇÁ¦·Î {serverAddress} ¶ó°í Çسõ´õ¶ó°í ½ÇÁ¦ °æ·Î ¼¼±×¸ÕÆ®´Â ¾Æ·¡¿Í °°Àº ¸ÅĪÀÌ ÀϾ°Ô µÇ¹Ç·Î,
{serverAddress}[.].*
// ^ literally a dot
192.168.200.1 °ú °°ÀÌ °ªÀ» ÇÒ´çÇصµ 192.168.200 ¸¸ ĸÃçµÈ´Ù´Â °ÍÀÌ´Ù.
|