Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8697529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:32:56+00:00 2026-06-13T01:32:56+00:00

As with many a new person to Spring MVC I am having difficulty getting

  • 0

As with many a new person to Spring MVC I am having difficulty getting over that first hurdle. In my case the current hurdle appears to be related to JSTL fmt taglib not formatting my dates properly or it is being passed a string literal by the value attribute of the fmt tag . I have a simple Maven project which I am using to work out the kinks in my knowledge. The following code snippets are from my WelcomeController, web-servlet.xml, web.xml and welcome.jsp.

WelcomeController.java

    @Controller
    @RequestMapping(value="/")
    class WelcomeController {  

        @RequestMapping(method=RequestMethod.GET) 
        public String welcome(Model model) {
            Date today = new Date();
            System.out.println("Controller being called");
            model.addAttribute("today", today);
            System.out.println(model.containsAttribute("today"));
            return "welcome";
       }
    }

web-servlet.xml

   <?xml version="1.0" encoding="UTF-8"?>
   <beans> <!-- bean namespaces ommitted for space sake -->

        <context:component-scan base-package="org.opel.eros.web"/>

        <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>

        <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>

        <context:property-placeholder location="classpath:META-INF/properties/web-config.properties"/>

        <mvc:annotation-driven/>

        <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="prefix" value="${config.prefix}"/>
            <property name="suffix" value="${config.suffix}"></property>
        </bean>

web.xml

   <web-app>
       <servlet>
            <servlet-name>eros</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
       </servlet>

       <servlet-mapping>
           <servlet-name>eros</servlet-name>
           <url-pattern>/</url-pattern>
       </servlet-mapping>
   </web-app>

And finally welcome.jsp

   <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
   <html>
   <head></head>
   <body>
       <fmt:formatDate value="${today}" pattern="yyyy-MM-dd"/>
   </body>
   </html>

Doesn’t get much simpler I know, but an exception is thrown when I enter the url http://localhost:9990/XYZ/, this is the exception: PWC6338: Cannot convert “${today}” for the attribute value of the bean java.util.Date

That seems to me to be an error where the formateDate is being passed the String literal “${today}”, which will obviously throw an exception. The example I am using to help (from Spring Reciepes: A problem Solution Approach) states that to access model attributes you use the syntax specified in the fmt tag above.

Basically I am looking for a solution and a reason why this is happening ( I do realise it is probably something really simple and stupid on my part =]). Thanks for any help in advance, much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:32:58+00:00Added an answer on June 13, 2026 at 1:32 am

    The problem seems to be inside the web.xml. The web.xml and corresponding project structure were auto generated by Spring Source tools using the maven-archtype-webapp. The auto generated web.xml doesn’t specify any namespace defenitions; Instead specifying a DOCTYPE similar to this:

    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" >
    

    I made the mistake of assuming that the auto generated code would use the version 3.0 definitions. A change to version 3 fixed the issues. One thing to note is that while the system was obviously using version 2.3 the output from calls to:

    -application.getMajorVersion(); and
    -application.getMinorVersion();
    

    Produced a Servlet version of 3.0, which lead to some confusion on my part and may catch other people out. Big thanks to Bogdan for his help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a new website that is linked to from many places but the
I've worked/seen a few spring-hibernate web application projects having as many interfaces as there
The current situation is that there is a databound data grid view that many
I'm new to the Win32 API and the many new types begin to confuse
As many other developers new to Cocoa, I struggle with delegate and controller concept.
Many Flex books seem to focus on people new to programming. E.g. I bought
I'm new at javascript and while there are many more complex solutions, I don't
I have just created a new project with a many-to-many relation (User-Group) and the
I am new to Javascript coding and have looked for this information in many
I am new to both Qt and Linux C++ development (although I have many

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.