스프링 bean에 액세스해야하는 스프링 MVC 컨트롤러로 변환해야하는 서블릿을 처리했습니다. 일반적인 서블릿 request.getPathInfo()
은 왜 반환하지 않고 null
이 아니지만, 스프링 컨트롤러에서 null 값을 받습니까? 나는 @PathVariable
을 사용할 수 있지만이 방법의 결과가 왜 다른지 궁금해하십니까?Spring MVC 컨트롤러 - getPathInfo()가 null입니다.
@RequestMapping(value = {"/test", "/test/*"})
public void test(HttpServletRequest req, HttpServletResponse res) {
log.info(req.getPathInfo() == null); // true!
if (req.getMethod().equalsIgnoreCase("get")) {
// analogue to doGet...
} else {
// analogue to doPost...
}
}
당신이 치고있는 URL은 무엇입니까? –
URL : http : // localhost : 8080/myApp/test/hello'. 'req.getPathInfo()'shuld return'/ hello' – marioosh