Bonjour,

Je réalise une application web ou j'utilise éclipse indigo, tomcat 7.0, Hibernate 4.1.1 et Spring 3.1.1.

J'ai voulu mettre en place l'internationalisation. J'ai donc crée deux fichiers properties

messages_en.properties
messages_fr.properties

Quand j’exécute mon programme et que je change de langue, il se passe rien. Je reste toujours en français et j'ai l'impression que seule le fichier messages_fr.properties est utilisé.

fichier application-context.xml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
		http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
		http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
 
	<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
		<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
		<property name="url" value="jdbc:mysql://localhost/hibernate"/>
		<property name="username" value="root"/>
		<property name="password" value="admin"/>
	</bean>
 
	<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
		<property name="dataSource" ref="dataSource"/>
		<property name="annotatedClasses">
			<list>
				<value>app.model.FieldOwnedRecords</value>
				<value>app.model.OwnRecord</value>
				<value>app.model.Updatehistory</value>
				<value>app.model.Evaluation</value>
				<value>app.model.Soundtrack</value>
				<value>app.model.Playlist</value>
				<value>app.model.Comment</value>
				<value>app.model.Field</value>
				<value>app.model.Artist</value>
				<value>app.model.AuthenticatedUser</value>
        		<value>app.model.Record</value>
			</list>
		</property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>	
			</props>
		</property>
	</bean>
 
	<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory"/>
	</bean>
 
	<tx:annotation-driven transaction-manager="transactionManager"/>
	<context:component-scan base-package="app" />
	<context:annotation-config/>
	<mvc:annotation-driven />
 
	<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    	<property name="basename" value="classpath:messages" />
   		 <property name="defaultEncoding" value="UTF-8"/>
	</bean>
 
 	<bean id="localeResolver"
		class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
		<property name="defaultLocale" value="fr" />
	</bean>
 
	<bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
    	<property name="paramName" value="lang" />
	</bean>
 
	<bean id="handlerMapping" class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
    	<property name="interceptors">
        	<ref bean="localeChangeInterceptor" />
    	</property>
	</bean>
</beans>

fichier header.jsp

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta charset="utf-8">
    <title>Vinyl Record Collection Manager</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
 
    <!-- styles -->
    <link href="bootstrap/css/bootstrap.css" rel="stylesheet">
    <style type="text/css">
      body {
        padding-top: 60px;
        padding-bottom: 40px;
      }
      .sidebar-nav {
        padding: 9px 0;
      }
    </style>
    <link href="bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
 
    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
</head>
 
<body>
 
<div class="navbar navbar-fixed-top">
  <div class="navbar-inner">
    <div class="container-fluid">
      <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </a>
      <a class="brand" href="index.jsp">Vinyl Record Collection Manager</a>
      <div class="nav-collapse">
        <ul class="nav">
          <li><a href="index.jsp"><spring:message code="label.accueil"/></a></li>
          <li><a href="collection.html"><spring:message code="label.collection"/></a></li>
          <% 	if(session.getAttribute("nom") != null) out.println("<li><a href='userProfil.html'>Mon Profil</a></li>");
          		else {
          			out.println("<li><a href='userLogin.html'>Me Connecter</a></li>");
          			out.println("<li><a href='userRegister.html'>M'Inscrire</a></li>"); 
          		}%>
          		<p class="navbar-text pull-right">
    		<a href="?lang=fr">fr</a>
    |		<a href="?lang=en">en</a>
		</p>
        </ul>
 
        <% if(session.getAttribute("nom") != null) out.println("<p class='navbar-text pull-right'>Connecté en tant que <a href='profil.jsp'>"+session.getAttribute("nom")+"</a>.  <a href='logout.jsp'>Déconnexion</a></p>");
        else out.println("<p class='navbar-text pull-right'>Vous n'êtes pas connecté. <a href='userLogin.html'>Connectez-vous</a></p>");%>
      </div><!--/.nav-collapse -->
    </div>
  </div>
</div>
 
<div class="container-fluid">
      <div class="row-fluid">
merci d'avance