velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Baisak, Ranjan" <ranjan.bai...@razorsight.com>
Subject Velocity integration with Spring
Date Mon, 15 May 2006 16:52:31 GMT
The Spring controller contains following codes
public ModelAndView handleRequest(HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) {

Collection channels = channelDAO.getHomeUris();
ModelAndView view = new ModelAndView("index","channelDAO",channelDAO);
view.addObject("message",greeting);
view.addObject("homeuris",channels);
return view;
}

In Velocity template, When I am trying to use channelDAO or message or homeuris collection
it returns following exception

Velocity code:
#set($greeting = $req.getAttribute("message"))
$greeting
#set($channelDAO = $req.getAttribute("channelDAO") )
#set($channels = $req.getAttribute("homeuris"))
#foreach ( $item in $channels)
On this iteration, \$item refers to the value $item.
#end

Exception:

(app.VelocityEngine 43 ) RHS of #set statement is null. Contex
t will not be modified. /html/index.vm [line 90, column 17]
(app.VelocityEngine 46 ) org.apache.velocity.runtime.exception
.ReferenceException: reference : template = /html/index.vm [line 91,column 17] :
$greeting is not a valid reference.
(app.VelocityEngine 43 ) RHS of #set statement is null. Contex
t will not be modified. /html/index.vm [line 92, column 17]

I am sure messageDAO, or homeuris or homeuris has been initialized before adding to view object.
Any suggestion?

regards,
Ranjan

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message