在Windows XP中为Tomcat服务设置默认语言环境

时间:2009-07-20 13:18:19

标签: java tomcat service locale

我在Windows XP计算机(法语)中安装了Apache Tomcat 6即服务

我的问题是Tomcat本身和所有webapps(Sonar和Hudson)现在都显示法语消息。 我当然想要英文信息,所以我进入控制面板的“区域设置”窗口并将所有内容更改为英语(美国)

Tomcat在法语中仍然。什么都没有改变。

我怀疑因为它作为服务运行,所以它不会从控制面板中选择设置。

那么有没有办法欺骗Tomcat JVM以便它使用英语而不是法语? 我有sys管理员访问机器(XP PRO法语)

谢谢

5 个答案:

答案 0 :(得分:26)

您需要正确设置user.languageuser.region

e.g。

java -Duser.language=en -Duser.region=CA
在您的Tomcat启动中

(可能是catalina.bat)。请查看this link以获取更多信息,以及对上述有效ISO代码集的引用。

答案 1 :(得分:3)

尽管我尝试了上面的一些建议,Tomcat经理却为我出现了法语。问题结果是特定于浏览器。 Chrome有"法语"作为我的一种语言列出,一旦我从偏好列表中删除它并刷新页面,Tomcat就会出现英文版本。我希望这对将来遇到这类问题的人有所帮助。

答案 2 :(得分:1)

在服务参数中指定语言选项。

$ Tomcat / bin / javaw.exe移至Java选项卡并在Java选项中指定-Duser.language = en -Duser.region = CA:

答案 3 :(得分:1)

区域设置是按用户划分的,服务是以不同的用户身份运行的(可以在“控制面板”/“管理工具”/“服务”中查看每个服务使用的用户)。

因此,您更改了用于登录的用户帐户的设置,而Tomcat服务则在其他帐户下运行。

答案 4 :(得分:0)

不幸的是,运行Tomcat服务时,Windows不会执行catalina.bat(或catalina.sh),因此catalina.bat修改无法解决此问题。

解决方案是手动运行服务(或重新安装服务),将这些参数添加到服务的执行中。这是为了执行此操作必须运行或安装服务的规范:

https://tomcat.apache.org/tomcat-6.0-doc/windows-service-howto.html(Tomcat 6) https://tomcat.apache.org/tomcat-7.0-doc/windows-service-howto.html(Tomcat 7)

根据此规范,要运行建立en_US语言环境的Tomcat6服务,您应该执行:

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = JhipsterAuthenticatedApp.class)
@WebAppConfiguration
@IntegrationTest
@WithMockUser(username = "user", roles = "ROLE_USER")
//@WithUserDetails("user")
public class UserProfileResourceIntTest {

    @Autowired
    private FilterChainProxy springSecurityFilterChain;

    @PostConstruct
    public void setup() {
        MockitoAnnotations.initMocks(this);
        UserProfileResource userProfileResource = new UserProfileResource();
        ReflectionTestUtils.setField(userProfileResource, "userProfileService", userProfileService);
        this.restUserProfileMockMvc = MockMvcBuilders.standaloneSetup(userProfileResource)
            .setCustomArgumentResolvers(pageableArgumentResolver).setMessageConverters(jacksonMessageConverter)
            .apply(SecurityMockMvcConfigurers.springSecurity(springSecurityFilterChain)).build();
    }

    @Test
    @Transactional
    public void createUserProfile() throws Exception {

        // Create the UserProfile
        restUserProfileMockMvc.perform(post("/api/user-profiles")
        //                .with(user("user").roles("USER"))
        .contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(userProfile)))
            .andExpect(status().isCreated());
      (...)
 }

在上面的链接中,还有一些如何安装和删除服务的示例。

希望这有帮助!