문제

I'm new to Spring MVC.

I have URLs like this:

  • localhost:8080/spring-mvc-project-web-war/searchProjects
  • localhost:8080/spring-mvc-project-web-war/searchProjects/

The difference is the "/" at the end of each URL.

Both render a page with the same content. The content includes a search button, which will search through database and return a list of results. But the first URL always returns HTTP 404 - /spring-mvc-project-web-war/searchProjects and the second still works fine.

Can anyone explain this for me?

I know this is the problem of handler mapping but I don't really understand it clearly.

도움이 되었습니까?

해결책

I think it's none of Spring HandlerMapping business.

when you click search button, the form http url posted depends on http base uri and your relative path(usually in action attribute)

"localhost:8080/spring-mvc-project-web-war/searchProjects" it's base uri is

localhost:8080/spring-mvc-project-web-war/

and "localhost:8080/spring-mvc-project-web-war/searchProjects/" base uri is

localhost:8080/spring-mvc-project-web-war/searchProjects/

In order to further understand,we can read Fielding's rfc document [Page 11]

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top