Spring MVC Controller - getPathInfo () is null

I worked a servlet that needs to be converted to a Spring MVC controller in order to have Spring beans access, etc. Why in the normal servlet request.getPathInfo()return not null, but in Spring Controller I get a null value? I know what I can use @PathVariable, but I wonder why the results of this method are the difference?

@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...
    }

}
+5
source share
1 answer

I think the solution is in javadoc getPathInfo ()

Additional path information follows the servlet path, but is preceded by a query string and starts with the "/" character.

Spring , , getServletPath(), URI, getPathInfo() .

+6

All Articles