Search code examples
jspmavenjstlresourcebundle

Resource Bundle in JSTL shows question marks?


In my login.jsp i have the following:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<fmt:setLocale value="${sessionScope.locale}" />
<fmt:setBundle basename="com.ubbcluj.project.res.myProp" />
<!DOCTYPE html>

And try to display the username in the following manner:

myProp.properties files looks like this and is located in "/Project/src/main/java/com/ubbcluj/project/res":

username = Username
pass = Password
register = Register
login = Login

When the page loads it appears in the following way: ???username???

I have tried adding a variable as shown in other tutorials like :

<fmt:message key="username" var="${lang}" />

But still didnt work.

I can share my whole project , i know its not perfect ,but it's only a study project any suggestions are welcome. https://www.dropbox.com/sh/biavimrexisfskp/o9q57IoiUl


Solution

  • You're building your project with Maven, and Maven expects non-Java files to be in src/main/resources, and not in src/main/java (which should only contain .java files). So your properties file is not copied to the target directory and included into the deployed application.