Results 1 to 2 of 2

Thread: Jstl fmt MessageFormat MessageSource (strange)

  1. #1
    Join Date
    Oct 2004
    Posts
    1

    Default Jstl fmt MessageFormat MessageSource (strange)

    Code:
    	<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">	
    		<property name="basename"><value>messages</value></property>										
    	</bean>

    Code:
    <jsp&#58;useBean id="now" class="java.util.Date" />
    
      <fmt&#58;message key="nowkey">
        <fmt&#58;param value="$&#123;now&#125;" />
      </fmt&#58;message>
    messages.properties
    nowkey = hello {0, date, yyyyMM}

    and the result always be "hello 10/11/04 10:24 AM "

    modify the messages.properties file
    nowkey = hello222 {0, date, yyyyMM}

    and the result will be "hello222 10/11/04 10:24 AM "

    if I setBundle in jstl, the result is correct !

    it be "hello222 200410"

    Code:
    	<fmt&#58;bundle basename="messages"> 
          <fmt&#58;message key="nowkey"> 
                     <fmt&#58;param value="$&#123;now&#125;"> 
                  </fmt&#58;param> 
             </fmt&#58;message> 
    	</fmt&#58;bundle>
    how to resolve this problem?
    could I solve this problem without explicitly specify the bundle in every

    jsp file?

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    I'd suggest separating pure date formatting from the message.
    Code:
    helloKey=hello
    nowkey=yyyyMM
    Code:
        <fmt&#58;message key="nowkey" var="pattern"/>
        <fmt&#58;formatDate value="$&#123;now&#125;" type="date" pattern="$&#123;pattern&#125;"/>

Similar Threads

  1. Template engine + JSTL
    By simtin in forum Web
    Replies: 5
    Last Post: Sep 6th, 2005, 03:18 AM
  2. Stack Overflow
    By rayho222 in forum Container
    Replies: 6
    Last Post: May 17th, 2005, 03:42 AM
  3. Replies: 1
    Last Post: Apr 13th, 2005, 04:46 PM
  4. Replies: 2
    Last Post: Feb 23rd, 2005, 11:43 AM
  5. JSTL 1.0 why?
    By robododge in forum Web
    Replies: 4
    Last Post: Nov 11th, 2004, 12:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •