::: Zany's Homepage ::: Zany Wiki | »çÀÌÆ® ÅëÇÕ °Ë»ö
 
 
 

[spring] @RequestMapping °æ·Î ¸¶Áö¸·¿¡ @PathVariable ·Î IP ÁÖ¼Ò¸¦ ¹Þ´Â °æ¿ì À߸² Çö»ó.

°Ô½ÃÆÇ
JAVA
ÀÛ¼ºÀÚ
helix
ÀÛ¼ºÀÏ
2016-07-25 10:20:44
ÀÐÀº¼ö
3543
ÆòÁ¡
   
Ç¥½Ã¿É¼Ç
HTML»ç¿ë | ÀÚµ¿BRűנ| °ø¹é¹®ÀÚÇã¿ë | °¡¿îµ¥Á¤·Ä | °íÁ¤Æø±Û²Ã | ÀÚµ¿URL¸µÅ© | ¸¶¿ì½º¼±ÅÃ
°ü·Ã¸µÅ©01
http://stackoverflow.com/questions/24946322/spring-pathvariable-without-ending-slash-string-with-ip-address 
¿ø¹® : 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 ¸¸ ĸÃçµÈ´Ù´Â °ÍÀÌ´Ù.


 °Ô½ÃÆÇ ±Û ¸ñ·Ï
No Subject Poster Hits Posted
13733 helix 2114 2016-09-27 17:24:48
13730 helix 1009 2016-09-27 11:13:00
13729 helix 8028 2016-09-27 10:12:57
13724 helix 2393 2016-09-26 17:35:48
13573 helix 8818 2016-07-28 09:49:13
helix 3543 2016-07-25 10:20:44
13379 helix 1715 2016-05-19 10:03:11
13368 helix 7077 2016-05-16 10:59:59
13157 helix 2428 2016-01-19 18:39:12
12975 helix 6552 2015-12-14 13:46:03
11339 helix 4101 2015-04-28 12:44:52
ÄÚ¸àÆ®
ÀÛ¼ºÀÚ
                       
 
zany.kr
  Copyright ¨Ï 2002-2010 Zany's Programming Lab. All Rights Not Reserved.
temporary This Page loads on 0.016 Secs