2
다음에 새 사용자 세션이 생성되도록 브라우저로 요청 로케일을 저장하려고합니다. 이 '로켈'쿠키가 읽혀지고 특정 페이지가 표시됩니다. struts2에서이 작업을 수행 할 방법이 필요합니다.Struts2 쿠키에 로케일 저장
다음에 새 사용자 세션이 생성되도록 브라우저로 요청 로케일을 저장하려고합니다. 이 '로켈'쿠키가 읽혀지고 특정 페이지가 표시됩니다. struts2에서이 작업을 수행 할 방법이 필요합니다.Struts2 쿠키에 로케일 저장
Struts에는 빌드 기능이 없습니다.
먼저 당신이
document.cookie = "locale_cookie=fa_IR";
둘째는 I18nInterceptor
를 확장하고 getLocaleFromParam
을 변경 자바 스크립트
@Override
getLocaleFromParam() {
//read cookie and find cookie which its name is locale_cookie
Cookie[] cookies = ServletActionContext.getRequest().getCookies();
for (int i = 0; i < cookies.length; i++) {
if("locale_cookie".equals(cookie.getName()){
return LocalizedTextUtil.localeFromString(cookie.getName());
}
}
..............
//The rest method
}
:
이 방법은 몇 가지가 아래처럼 생각해야한다 쿠키 읽기 –