IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Spring Java Discussion :

Liaison avec fichier de langues


Sujet :

Spring Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    130
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Avril 2007
    Messages : 130
    Par défaut Liaison avec fichier de langues
    Salut
    Je dev une webapps avec Spring je veux crée un fichier messages.properties dans WEB-INF/classes/
    quand j'y fait appelle je n'obtient que des ???heading???

    voici le fichier messages.properties
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    title=SpringApp
    heading=Hello :: SpringApp
    greeting=Greetings, it is now
    voici mon fichier de config
    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
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" 'http://www.springframework.org/dtd/spring-beans.dtd'>
    	<beans>
     
    <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
        <property name="basename" value="/WEB-INF/messages"/>
        <property name="cacheSeconds" value="1"/>
    </bean>
     
    Note that you h
     
    		<bean id="livre" class="livre.Livre">
    	        <property name="id" >
    				<value>1</value>
    	        </property>
    	        <property name="nom">
    	        	<value>nom</value>
    	        </property>
    	        <property name="auteur">
    	        	<value>auteur</value>
    	        </property>
        	</bean>
     
     
     
    		<bean id="controller" class="web.SpringappController">
    			<property name="livre">
    	            <ref bean="livre"/>
    	        </property>
    	        <property name="livreMan">
                	<ref bean="livreServiceTarget"/>
            	</property>   
            </bean>
     
     
    		<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">        
    			<property name="mappings">            
    				<props>                
    					<prop key="/hello.htm">controller</prop>           
    				</props>        
    			</property>    
    		</bean>
     
     
     
    		<!-- ========================= Start of PERSISTENCE DEFINITIONS =========================-->
     
    		<!-- DataSource Definition -->
    		<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    			<property name="driverClassName">
    				<value>com.mysql.jdbc.Driver</value>
    			</property>
    			<property name="url">
    				<value>jdbc:mysql://localhost:3306/bdtest</value>
    			</property>
    			<property name="username">
    				<value>root</value>
    			</property>
    			<property name="password">
    				<value>root</value>
    			</property>
    		</bean>
     
    		<!-- Hibernate SessionFactory Definition -->
    		<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    			<property name="mappingResources">
    				<list>
    					<value>livre/livre.hbm.xml</value>
    				</list>
    			</property>
    			<property name="hibernateProperties">
    				<props>
    					<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
    					<prop key="hibernate.show_sql">true</prop>
    					<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
    					<prop key="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</prop>
    				</props>
    			</property>
    			<property name="dataSource">
    				<ref bean="dataSource" />
    			</property>
    		</bean>
     
    		<!-- Spring Data Access Exception Translator Defintion -->
    		<bean id="jdbcExceptionTranslator" class="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator">
    			<property name="dataSource">
    				<ref bean="dataSource" />
    			</property>
    		</bean>
     
    		<!-- Hibernate Template Defintion -->
    		<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
    			<property name="sessionFactory">
    				<ref bean="sessionFactory" />
    			</property>
    			<property name="jdbcExceptionTranslator">
    				<ref bean="jdbcExceptionTranslator" />
    			</property>
    		</bean>
     
    		<!-- Hibernate Transaction Manager Definition -->
    		<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    			<property name="sessionFactory">
    				<ref local="sessionFactory" />
    			</property>
    		</bean>
     
    		<!-- ========================= Start of DAO DEFINITIONS ========================= -->
     
    		<!-- TODO DAO Definition: Hibernate implementation -->
    		<bean id="livreDaoAble" class="livre.dao.LivreDaoImpl">
    			<property name="hibernateTemplate">
    				<ref bean="hibernateTemplate" />
    			</property>
    		</bean>
    		<!-- ========================= Start of SERVICE DEFINITIONS ========================= -->
     
    		<!-- TODO Service Definition -->
    <bean id="livreServiceTarget" class="livre.LivreServiceImpl">
    			<property name="livreDao">
    				<ref local="livreDaoAble" />
    			</property>
    		</bean>
     
    		<!-- Transactional proxy for the TODO Service -->
    		<bean id="livreService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    			<property name="transactionManager">
    				<ref local="transactionManager" />
    			</property>
    			<property name="target">
    				<ref local="livreServiceTarget" />
    			</property>
    			<property name="transactionAttributes">
    				<props>
    					<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
    					<prop key="save*">PROPAGATION_REQUIRED</prop>
    				</props>
    			</property>
    		</bean>
     
     
     
    	</beans>
    et voici ma jsp qui l'appel
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    <%@ include file="/WEB-INF/jsp/include.jsp"%>
     
    <html>
    <head>
    <title><fmt:message key="title" /></title>
    </head>
    <body>
    <h1><fmt:message key="heading" /></h1>
    <p><fmt:message key="greeting" /> <c:out value="${model.now}" /></p>
    <br>

  2. #2
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    130
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Avril 2007
    Messages : 130
    Par défaut
    Personne n'a une petite idée??

  3. #3
    Rédacteur
    Avatar de Hikage
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    1 177
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2004
    Messages : 1 177
    Par défaut
    A premiere vue tu parle d'un Bundle messages.properties dans WEB-INF/classes/

    Et au niveau du fichier configuration : /WEB-INF/message ( sous entendu /WEB-INF/message.properties )

    Donc il y a de forte chance que Spring ne trouve pas le fichier, vérifie si c'est cela.
    Hikage
    SCJP / SCWCD & SCWSJD Certified / Spring Framework Certified
    [Personal Web] [CV]

    F.A.Q Spring Framework - Participez !

  4. #4
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    130
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Avril 2007
    Messages : 130
    Par défaut
    Je viens de changer mon fichier de config par cela
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
        <property name="basename" value="WEB-INF/classes/messages"/>
    </bean>
    mais rien ne se passe de plus??
    l'appel dans la JSP est bonnes?

  5. #5
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    130
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Avril 2007
    Messages : 130
    Par défaut
    voici le fichier include.jsp si sa peut aider qq'un??

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    <%@ page session="false"%>
     
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>

  6. #6
    Membre chevronné

    Homme Profil pro
    Consultant informatique
    Inscrit en
    Juillet 2002
    Messages
    346
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Consultant informatique

    Informations forums :
    Inscription : Juillet 2002
    Messages : 346
    Par défaut
    Essaye just ça:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
        <property name="basename" value="messages"/>
        <property name="cacheSeconds" value="1"/>
    </bean>
    Car à ma connaissance, les Bundle sont chargé depuis le classpath donc pas besoin de mettre le WEB-INF.

    Sinon, utilise directement la FMT au lieu du support de Spring que je ne connait pas donc je ne peut pas te donner réellement d'aide sur comment il marche (d'ailleur , je ne l'ai pas trouvé dans le Javadoc de la 2.0, bizzar).
    Pour la FMT, tu met juste ces lignes là dans le web.xml:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    <context-param>
    	    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    	<param-value>messages</param-value>
    </context-param>

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [WD14] Liaison avec fichier de données hyperfileSQL
    Par willytito dans le forum WinDev
    Réponses: 5
    Dernier message: 07/03/2011, 11h50
  2. [XL-2003] Liaisons avec fichiers fermés
    Par William-Michel dans le forum Excel
    Réponses: 8
    Dernier message: 09/02/2011, 11h07
  3. Réponses: 11
    Dernier message: 14/03/2007, 14h39
  4. Fichier de langue avec des caractères chinois
    Par marcootz dans le forum C++Builder
    Réponses: 4
    Dernier message: 11/01/2007, 18h54
  5. Prbleme de liaison avec des doublons dans le fichier lié.
    Par krak70 dans le forum Langage SQL
    Réponses: 3
    Dernier message: 16/10/2005, 11h03

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo