2011-12-09 3 views
3

자바 1.6, 스트럿츠 2.0.11, 윈도우 OSstruts.custom.i18n.resources 속성을 특정 폴더로 어떻게 설정할 수 있습니까?

나는 특성이 외부 src 패키지 폴더를 파일 기반의 모듈 고유의 라벨을 배치 struts.xml에서해야하는 일 구성

?

이유 : 별도의 모듈 기반 폴더에서 모든 국제화 기반 속성을 그룹화 하시겠습니까?

WEB-INF 
    |_classes 
    | |__com 
    |  |__xyz 
    |   |__Hellofoo.class 
    | 
    |__ struts.xml 
    | 
    |__props 
     |__xyz 
      |_ en.properties [ English Labels ] 
       jp.properties [ Japanese Labels] 
       spn.properties[ Spainish Labels ] 

답변

1

나는 당신이 struts.xml 파일 또는

struts.custom.i18n.resources=global-messages, image-messages 

같은 또는

<constant name="struts.custom.i18n.resources" value="global-messages, image-messages" /> 

가 또는 일부를 사용할 수있는 것처럼 XML 파일의 등록 정보 파일 속에서 이것을 지정할 필요가 있다고 생각 귀하의 필요에 따라 그것을 사용자 정의 할 Listener 일종의.

IMO 텍스트 리소스는 지역 및 패키지별로 구성해야하지만 선택의 문제입니다.

+0

을 안녕 >> struts.xml 파일 또는 등록 정보 파일에서 대부분의 Struts2 개발자는 "i18n.resources"파일을 * .java와 함께 배치합니다. 각 패키지 ... 이는 런타임 레이블 대체 프로세스에 대한 STRUTS2의 일반적인 관행입니다. 필자의 경우, 파일을 Java 패키지 외부에 배치하고 싶습니다 (위의 스케치에서 설명한대로). 정확히 구성을 수행해야합니다 무엇? ... –

+0

가장 좋은 방법은 이러한 경우에 청취자를 위해 이동하는 것입니다 –

+0

안녕 리스너 프로세스가 실행 시간 레이블 선택 과정 jp.properties [일본어 레이블] SPN입니다. properties [Spainish Labels] –

1

내가 지금이 정말없는 서버가

URL[] urls; 
try { 
    File file = new File("/your path"); 
    URL url = file.toURI().toURL();   
    urls = new URL[]{url}; 

    ClassLoader cl = new URLClassLoader(urls); 
    LocalizedTextUtil.setDelegatedClassLoader(cl); 
    LocalizedTextUtil.addDefaultResourceBundle("globalMessages"); 
} catch (MalformedURLException e) { 
    e.printStackTrace(); 
} 
1

을 시작할 위치를 실행합니다 당신의 StartupServlet 또는 다른 곳으로 아래의 코드를 추가 한 후 struts.custom.i18n.resources=globalMessages struts.properties

먼저 해결책을 발견 귀하의 특정 질문에 대한 답변. 그러나 나는이 페이지에서 "특정 폴더 (src 폴더 안에 있지만 바로 아래에 있지 않음)에 struts.custom.i18n.resources 속성을 설정하려면 어떻게 할 수 있습니까? 내가 struts.properties에서 다음을 설정할 때 난 struts.xml에서 설정하면

자, 그러나

struts.custom.i18n.resources=resources/locale-bundles/label-values,resources/locale-bundles/error-values 

작동하지 않습니다, 그것은하지 않습니다. (어떤 생각이 왜)

<constant name="struts.custom.i18n.resources"  
value="resources/locale-bundles/label-values, resources/locale-bundles/error-values" /> 
관련 문제