Retrieve browser locale from httpsession?

后端 未结 3 1955
梦如初夏
梦如初夏 2021-01-22 10:19

Is it possible to derive the preferred language from a httpsession object (javax.servlet.http.HttpSession) ? It is possible to get it from the servletrequest but I dont have tha

3条回答
  •  有刺的猬
    2021-01-22 10:41

    The preferred Locale for a user is available as a request header ("Accept-Language"). It is automatically filled in by the user's browser according to its preferences. Then, you can store this info in the user's session and retrieve it later when appropriate.

提交回复
热议问题