1,使用annotation 声明控制器
<mvc:annotation-driven />
<context:component-scan base-package="com.sf.cc.controller" /></bean>
5.html代码
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery(".v").on("click", function() {
jQuery(".vif").attr("src", "vm/velo.hm");
});
});
</script>
<title>Velocity-Ajax</title>
</head>
<body>
<iframe class="vif"></iframe>
<input class="v" type="button" value="olo" />
</body>
6.模版
#set( $this = "Velocity")
$this is great!
#foreach( $name in $list )
$name
#end
#set( $condition = true)
#if ($condition)
The condition is true!
#else
The condition is false!
#end
author $author
7.控制器
@Controller
public class VelocityController {
// http://xxx.renren.com/vm/velo.hm
@RequestMapping("/vm/velo")
public ModelAndView v() {
ModelAndView mav = new ModelAndView("hello");
ArrayList<String> list = new ArrayList<String>();
list.add("<br/>System.currentTime:" + System.currentTimeMillis());
list.add("<br/>Welcome Velocity<br/>");
mav.addObject("list", list);
mav.addObject("author", "<br/>work");
return mav;
}
}