Results 1 to 4 of 4

Thread: Small spring/velocity config problem

  1. #1
    Join Date
    Oct 2004
    Posts
    27

    Default Small spring/velocity config problem

    Hi there,

    I'm new to Spring and Velocity and having a config issue - I think that I may be missing some part of the configuration. If I do a manual merge of a template and a velocity context, everything works fine. But when I try to do this in a web app with a view resolver, its like the spring is ignoring the model, and it will show an error like:

    "WARN - CommonsLoggingLogSystem.logVelocityMessage(45) | org.apache.velocity.runt
    ime.exception.ReferenceException: reference : template = login.vm [line 6,column 1] : ${loginError} is not a valid reference."

    Here is a snippet from my controller:

    public ModelAndView gotoLoginPage(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    {
    logger.info("gotoLoginPage request");
    ModelAndView mv;
    Map<Object, Object> model = new HashMap<Object, Object>();
    model.put("loginError", "false");
    mv = new ModelAndView("login", "model", model);
    return mv;
    }

    Here is my servlet config file snippet:
    <bean id="velocityConfig"
    class="org.springframework.web.servlet.view.veloci ty.VelocityConfigurer">
    <property name="resourceLoaderPath"><value>/WEB-INF/velocity/</value></property>
    </bean>

    <bean id="viewResolver"
    class="org.springframework.web.servlet.view.veloci ty.VelocityViewResolver">
    <property name="cache"><value>false</value></property>
    <property name="prefix"><value></value></property>
    <property name="suffix"><value>.vm</value></property>
    </bean>

    Any hints/suggestions MUCH appreciated!

    Javatar

  2. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    I think you should use:
    Code:
    mv = new ModelAndView&#40;"login", model&#41;;
    HTH
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  3. #3
    Join Date
    Oct 2004
    Posts
    27

    Default

    Thanks man, that did it. Ugh, and I stared that in the face for 1 1/2 hours last night. I had it previously setup for JSTL and the three parameter method worked fine.

    THANK AGAIN!

    Javatar

  4. #4
    Join Date
    Oct 2004
    Posts
    27

    Default

    Ugh, just to followup. I was looking at the images project in the samples folder of spring and there the 3 param method is used, successfully:

    return new ModelAndView("imageList", "images", this.imageDatabase.getImages());

    The 3 params method will work properly, but I was incorrectly referencing the variable. Instead of:

    ${loginError}

    I should have used:
    ${model.loginError}

    Blech, my mistake. OK, time to go have a cup of Java and put my head on straight

    Cheers,

    Mark

Similar Threads

  1. Replies: 19
    Last Post: Sep 10th, 2007, 12:46 PM
  2. Replies: 10
    Last Post: Jul 30th, 2005, 07:59 PM
  3. Replies: 2
    Last Post: May 2nd, 2005, 05:33 AM
  4. Replies: 1
    Last Post: Apr 13th, 2005, 10:08 PM
  5. extending AbstractXmlApplicationContext problem
    By bryanhunt in forum Container
    Replies: 2
    Last Post: Aug 31st, 2004, 04:01 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
  •