源代码在附件中
主要配置:
java类代码:
访问jsp 页面:
@Controller
@RequestMapping("/jsp")
public class JspController {
@RequestMapping("/list")
public ModelAndView list(){
ModelAndView modelAndView = new ModelAndView("list.jsp");
modelAndView.addObject("name", "jsp........");
return modelAndView;
}
}
访问ftl页面:
@Controller
@RequestMapping("/ftl")
public class FtlController {
@RequestMapping("/hello")
public ModelAndView hello(){
ModelAndView model = new ModelAndView("hello.ftl");//文件后缀必须填写
model.addObject("name", "boce...");
return model;
}
}
访问 vm页面:
@Controller
@RequestMapping(value = "/demo")
public class DemoVelocity {
// Logger logger = LoggerFactory.getLogger(VelocityDemo.class);
@RequestMapping(value = "/welcome")
public String index(Model model) throws Exception {
model.addAttribute("name", "highkgao");
model.addAttribute("age", 20);
model.addAttribute("date", Calendar.getInstance().getTime());
//model.a
System.out.println(model.toString());
return "welcome.vm"; //文件后缀必须填写
}
@RequestMapping(value = "/test.do")
public String test(Model model) throws Exception {
model.addAttribute("name", "highkgao");
System.out.println(model.toString());
return "index";
}
@RequestMapping(value="/autoBind", method={RequestMethod.GET})
public String autoBindLogin(Model model){
model.addAttribute("accountmodel", new AccountModel());
return "login";
}
@RequestMapping(value="/autoBind2", method={RequestMethod.POST})
public String autoBindResult(Model model,AccountModel am){
model.addAttribute("accountmodel",am );
return "autoBindResult";
}
}
访问后页面显示:
jsp页面:

vm页面

ftl页面
