사실 심심하지는 않다. 스프링 3.1의 내용을 추가한 토스3 개정판 원고를 쓰느라 저녁과 주말의 개인시간을 모두 바쳐야 하는 폐인 생활을 하고 있을 뿐.

아무튼 @RequestMapping에 들어가는 7가지 조건의 조합을 정리하다 보니 이런 내용은 간단한 퀴즈로 만들면 재밌겠다 싶다.

컨트롤러의 @RequestMapping 설정을 보고 hello() 라는 메소드가 호출되게 할 수 있는 HTTP 요청의 개수가 얼마나 될지 세어보는 간단 문제.

먼저 간단한 샘플.

@Controller
public class MyController {
  @RequestMapping({“/a”, “/b”})
  public void hello() {}

이 컨트롤러의 hello 메소드가 실행되게 만들 수 있는 HTTP 요청 조건은 2가지다. URL이 /a 인 경우와 /b인 경우. 물론 나머지 조건(파라미터, 요청 메소드, 헤더 등등)은 어떻든 상관없고.

이제 실전 문제.

1.
@Controller
@RequestMapping({“/a”, “/b”})
public class MyController {
  @RequestMapping({“/c”, “/d”})
  public void hello() {}

2.
@Controller
@RequestMapping(params={“a”, “b”})
public class MyController {
  @RequestMapping(params={“c”, “d”})
  public void hello() {}

3.
@Controller
@RequestMapping(headers={“a”, “b”})
public class MyController {
  @RequestMapping(headers={“c”, “d”})
  public void hello() {}

4.
@Controller
@RequestMapping(headers={“a”, “Content-Type=application/json”, “Content-Type=multipart/form-data”})
public class MyController {
  @RequestMapping(headers={“c”, “d”})
  public void hello() {}

 

5.
@Controller
@RequestMapping(headers={“a”, “b”})
public class MyController {
  @RequestMapping(headers={“c”, “d”, “Content-Type=application/json”}, consumes=”multipart/form-data”)
  public void hello() {}

 

6.
@Controller
@RequestMapping(consumes={“application/xml”, “application/x-www-form-urlencoded”})
public class MyController {
  @RequestMapping(consumes={”multipart/form-data”, “application/json”})
  public void hello() {}

1번부터 6번까지 컨트롤러의 hello() 메소드를 실행하게 만드는 HTTP 요청의 가짓수는 각각 몇개일까?

1,2,3번은 쉽고, 4,5,6번은 각 요청 조건의 결합 특성을 바르게 알고 있으면 어렵지 않다. 문제를 가능한 쉽게 만들기 위해서 한번에 나오는 조건의 종류는 최소화 했고, 인터페이스나 수퍼 클래스에 붙은 @RM의 경우도 안 넣었다.

코멘트에 답 주시는 분 중에서 정답자를 뽑아서 다음 달에 할까 하는 토스3 독자모임/세미나에 참가 우선권을 드리도록 하겠다.

아.. 아무도 관심이 없을지도. 원고나 쓰러 가야지.

Related posts:

  1. Inside Spring (6) 애노테이션 설정 지원 스프링 웹 테스트용 DispatcherServlet 만들기
  2. Spring ROO 대충대충 분석 (2) ROO란 무엇인가?
  3. Spring 상식퀴즈 (1) – DI 태클하기
  4. Spring 3.0 EL (Spel)을 이용한 AssertThrows 확장 (2)
  5. 토비의 스프링 3 간략 목차
  6. 스프링 빈의 이름은 한글로 지어도 된다
  7. Spring 3.0 (58) Static Class를 XML없이 빈으로 등록하기
  8. Spring ROO 대충대충 분석 (3) ROO의 Inter-type declaration
  9. Spring 3.0 EL (Spel)을 이용한 AssertThrows 확장 (1)
  10. 미리 보는 Spring 3.0.1의 변경사항
  11. 유쾌한 이슈처리 재촉 메일
  12. 스프링 3.1 (8) web.xml 없는 스프링 개발
  13. [토스3] 매핑 가능한 BeanPropertySqlParameterSource
  14. Spring 3.0 @MVC 메소드에서 자동으로 리턴 모델에 추가되는 것들
  15. S1A 2008 셋째날 – Spring JavaConfig

Facebook comments:

to “스프링 3.1 (10) 심심풀이 @RequestMapping 요청 조건 퀴즈”

  1. cheap ambien online highest dosage ambien – buy ambien online pharmacy

  2. This is amazing!

  3. best gucci mane quotes 스프링 3.1 (10) 심심풀이 @RequestMapping 요청 조건 퀴즈 » Toby’s Epril

  4. gucci mane spread the word free download 스프링 3.1 (10) 심심풀이 @RequestMapping 요청 조건 퀴즈 » Toby’s Epril

  5. free shipping jessica simpson shoes 스프링 3.1 (10) 심심풀이 @RequestMapping 요청 조건 퀴즈 » Toby’s Epril

  6. via spiga shoes discount 스프링 3.1 (10) 심심풀이 @RequestMapping 요청 조건 퀴즈 » Toby’s Epril

  7. mbt ari ebay 스프링 3.1 (10) 심심풀이 @RequestMapping 요청 조건 퀴즈 » Toby’s Epril

  8. what are mbt shoes 스프링 3.1 (10) 심심풀이 @RequestMapping 요청 조건 퀴즈 » Toby’s Epril

  9. I’d like to find outt more? I’d want to find out more details.

  10. lDDJU4 wow, awesome article post.Really thank you! Awesome.

  11. Hi, i think that i noticed you visited my website thus i
    came to go back the desire?.I am attempting to to find
    things to enhance my web site!I suppose its adequate to use some of your concepts!!

  12. I do agree with all of the ideas you’ve presented for your post.
    They’re really convincing and can certainly work.

    Nonetheless, the posts are too brief for starters.

    May you please prolong them a little from next time? Thanks for the post.

  13. Thank you for any other wonderful article. Where else may anyone get
    that type of info in such a perfect way of writing? I have a
    presentation subsequent week, and I am on the search for
    such info.

  14. It’s an awesome article in favor of all the internet users;
    they will obtain advantage from it I am sure.

  15. You really make it seem so easy along with your presentation however I find this matter to be actually something that I believe I’d never understand.
    It kind of feels too complex and very vast for me. I am looking forward on your subsequent put up, I
    will try to get the grasp of it!

  16. I read this piece of writing fully regarding the resemblance
    of most recent and earlier technologies, it’s amazing article.

  17. I am actually thankful to the holder of this site who has shared this enormous
    post at at this time.

  18. I’m very pleased to discover this web site. I want to to thank you for ones time for
    this fantastic read!! I definitely loved every bit of it and i also have you bookmarked to check
    out new stuff in your blog.

  19. whoah this weblog is excellent i love studying your posts.

    Stay up the good work! You realize, a lot of people are searching round for
    this information, you can help them greatly.

  20. What’s up to every body, it’s my first pay a visit of this webpage; this website consists of remarkable and really good data in support of readers.

  21. I blog frequently and I really thank you for your information. This article has really peaked my interest.
    I am going to bookmark your site and keep checking for new details about once per week.
    I opted in for your RSS feed as well.

  22. What’s up, its fastidious post concerning media print,
    we all be aware of media is a enormous source
    of facts.

  23. I relish, cause I found exactly what I was taking a look for.
    You’ve ended my four day long hunt! God Bless you man. Have
    a great day. Bye

  24. No matter if some one searches for his necessary thing, thus he/she needs to be available that in detail,
    therefore that thing is maintained over here.

  25. Unquestionably believe that which you stated.
    Your favorite justification seemed to be on the internet the easiest
    thing to be aware of. I say to you, I certainly get irked while people
    think about worries that they plainly don’t know about. You managed to hit the nail upon the top as
    well as defined out the whole thing without having side effect ,
    people could take a signal. Will likely be
    back to get more. Thanks

Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

© 2017 Toby's Epril Suffusion theme by Sayontan Sinha