简体   繁体   English

在不同的 PC 上找不到 ResourceBundle

[英]ResourceBundle not found at different PC

I have a Servlet project with JSP to which i made a i18n .我有一个带有 JSP 的 Servlet 项目,我为此做了一个i18n My resources.properties files are in src/main/resources/ and all working on my PC (Windows 10).我的resources.properties文件在src/main/resources/并且都在我的 PC(Windows 10)上运行。 I commited update to git, my friend fetched it, and it is not working.我提交了对 git 的更新,我的朋友获取了它,但它不起作用。 The resource bundle seems like not found.资源包似乎没有找到。 He has bundle var names instead of values.他有捆绑 var 名称而不是值。

In JSP i do: At the top <fmt:setBundle basename="resources"/> (resources is the bundle name), and every value replace with <fmt:message key="leftbar.librarian"/> When i want to change languages from JSP i made:在 JSP 中,我这样做:在顶部<fmt:setBundle basename="resources"/> (resources 是包名称),并且每个值都替换为<fmt:message key="leftbar.librarian"/>当我想更改时我制作的 JSP 语言:

<c:choose>
    <c:when test="${cookie.get('language').value == 'ru'}">
        <fmt:setLocale value='ru' scope="session"/>
    </c:when>
    <c:otherwise>
        <fmt:setLocale value='en' scope="session"/>
    </c:otherwise>
</c:choose>
<fmt:setBundle basename="resources"/>

and via JS i set cookies from click on button.并通过 JS 我通过单击按钮设置 cookie。 It is all working on my PC.这一切都在我的电脑上工作。 At three another PC the bundle is not loaded (but without errors).在另外三台 PC 上,捆绑包未加载(但没有错误)。

So, how i should define the bundle in Java, so others can get it?那么,我应该如何在 Java 中定义包,以便其他人可以得到它?

PS I am not used Java code to configure it. PS我没有使用Java代码来配置它。 All in JSP.全部在 JSP 中。 But ready to refactor if i am wrong.但如果我错了,准备重构。

Solved.解决了。 Tomcat not found recources from /resources path.找不到来自 /resources 路径的 Tomcat 资源。 So i had to move bundle to root.所以我不得不将 bundle 移到 root。 Now projects start on all PC`s现在项目在所有 PC 上启动

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM