spring - Property value is not printing on velocity template -


i using spring velocity , try print literal on velocity template, not working. here template, exportecomplete.vm:

${savepath} 

here code:

@override public modelandview handlerequest(httpservletrequest request, httpservletresponse response) throws exception {      ....     boolean success = processor.exportcourse(courseid, exportplayer, exportassets, exportjson);      ...     if (success) {         log.debug("export success");         return new modelandview("templatescene/exportcomplete");     } else {         log.debug("export failure");         return new modelandview("templatescene/exporterror", "context", context);     }  } 

here method:

public boolean exportcourse(string courseid, boolean exportplayer, boolean exportassets, boolean exportjson) {       context = new hashmap<object, object>();     context.put("savepath", "save path complete");     velocityengineutils.mergetemplateintostring(engine, "templatescene/exportcomplete.vm", "utf-8", context);      boolean test = true;      if (test) {              return true;             } } 

i end ${savepath} result, when view returns exportcomplete.vm.

why not printing value when view returns?

edit ------------------------------------------------------------

this working code.

@override public modelandview handlerequest(httpservletrequest request, httpservletresponse response) throws exception {      ....     context = new hashmap<object, object>();     boolean success = processor.exportcourse(courseid, exportplayer, exportassets, exportjson, context);     if (success) {         log.debug("export success");         return new modelandview("templatescene/exportcomplete", "context", context);      } else {         log.debug("export failure");         return new modelandview("templatescene/exporterror", "context", context);     }  } 

and here method

public boolean exportcourse(string courseid, boolean exportplayer, boolean exportassets, boolean exportjson, map<object, object> mycontext) {      ...     if (mycontext != null) {          mycontext.put("savepath", "save path complete");         return true;      }  } 

and here template

${context.savepath} 

savepath property of context map variable.

as proper way access context.get("savepath"), instead of:

${savepath} 

you should use:

${context.savepath} 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -