URL Path Parameter Use Cases

后端 未结 2 2164
失恋的感觉
失恋的感觉 2021-02-13 01:56

Normally when I think of parameters in an URL, I think of the query string. Technically, however, it is also legal to specify parameters in the path segments. Thus given a URL

2条回答
  •  不要未来只要你来
    2021-02-13 02:22

    Java Servlet Containers uses URL rewriting to maintain session state when the client does not support cookies by appending a path parameter. The servlet specification says the path parameter must be named jsessionid

    e.g. http://example.com/servlet_path;jessionid=E60FF3ABD2926AD9AA45513A385E373D

    To get this working you must be careful to always pass the URLs you send back to the client through response.encodeURL() or response.encodeRedirectURL() so that the container can add the necessary path parameter.

    Further support is demanded by the specification for mapping requests to servlets

    The path used for mapping to a servlet is the request URL from the request object minus the context path and the path parameters

提交回复
热议问题